I'm more or less new to JS in general and am currently trying to figure out how and why I do not have access to a previously defined server attribute.
In another file I attempt to import
const server = require('./..');
points to the right location as far as I can tell, and all other variables set in a similar manner work fine.
I'm assuming this is an issue in the server registration part of things with Hapi.
const init = async () => {
// Load dependencies
require('./conf/os.conf')();
require('./middleware');
const model = require('./model');
require('./routes');
require('./workers');
const server = module.exports = Hapi.server({
port: process.env.PORT,
});
await server.register([
require('hapi-async-handler'),
require('hapi-auth-bearer-token'),
require('hapi-overriding'),
require('inert'),
require('vision'),
{
register: require('hapi-swagger'),
options: {
documentationPath: `${process.env.API_BASEURL}/documentation`,
info: {
title: 'API Documentation',
version: process.env.API_VERSION,
contact: {
name: 'Mason Fraser',
email: 'myemail@email.com'
}
},
pathPrefixSize: 3,
basePath: `${process.env.API_BASEURL}/`
}
}, {
register: require('hapi-pagination'),
options: {
query: {
pagination: {
default: false
}
},
meta: {
baseUri: process.env.API_BASEURL,
limit: {
active: true
},
page: {
active: true
}
}
}
}
]);
// Trying things.
exports.plugin = {
register: (server, options) => {
server,
require('hapi-async-handler'),
require('hapi-auth-bearer-token'),
require('hapi-overriding'),
require('inert'),
require('vision')
}
}
await server.start();
console.log('Server running on %s', server.info.uri);
};
Any clues on how to fix this?