comm
parent
c7cf60b529
commit
55a0040734
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"extends": "@hapi/eslint-config-hapi",
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "script"
|
||||
}
|
||||
}
|
||||
{
|
||||
"extends": "@hapi/eslint-config-hapi",
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "script"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
node_modules
|
||||
server/.env
|
||||
node_modules
|
||||
server/.env
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
*
|
||||
!lib/**
|
||||
*
|
||||
!lib/**
|
||||
|
|
42
knexfile.js
42
knexfile.js
|
@ -1,21 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
const Path = require('path');
|
||||
const Hoek = require('@hapi/hoek');
|
||||
const Manifest = require('./server/manifest');
|
||||
const Plugin = require('./lib/plugins/@hapipal.schwifty');
|
||||
|
||||
// Take schwifty registration's knex option
|
||||
// but specify the plugin's migrations directory
|
||||
|
||||
module.exports = Hoek.applyToDefaults(
|
||||
{
|
||||
migrations: {
|
||||
directory: Path.relative(process.cwd(), Plugin.options.migrationsDir)
|
||||
}
|
||||
},
|
||||
Manifest
|
||||
.get('/register/plugins', process.env)
|
||||
.find(({ plugin }) => plugin === '@hapipal/schwifty')
|
||||
.options.knex
|
||||
);
|
||||
'use strict';
|
||||
|
||||
const Path = require('path');
|
||||
const Hoek = require('@hapi/hoek');
|
||||
const Manifest = require('./server/manifest');
|
||||
const Plugin = require('./lib/plugins/@hapipal.schwifty');
|
||||
|
||||
// Take schwifty registration's knex option
|
||||
// but specify the plugin's migrations directory
|
||||
|
||||
module.exports = Hoek.applyToDefaults(
|
||||
{
|
||||
migrations: {
|
||||
directory: Path.relative(process.cwd(), Plugin.options.migrationsDir)
|
||||
}
|
||||
},
|
||||
Manifest
|
||||
.get('/register/plugins', process.env)
|
||||
.find(({ plugin }) => plugin === '@hapipal/schwifty')
|
||||
.options.knex
|
||||
);
|
||||
|
|
28
lib/index.js
28
lib/index.js
|
@ -1,14 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
const HauteCouture = require('@hapipal/haute-couture');
|
||||
const Package = require('../package.json');
|
||||
|
||||
exports.plugin = {
|
||||
pkg: Package,
|
||||
register: async (server, options) => {
|
||||
|
||||
// Custom plugin code can go here
|
||||
|
||||
await HauteCouture.compose(server, options);
|
||||
}
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const HauteCouture = require('@hapipal/haute-couture');
|
||||
const Package = require('../package.json');
|
||||
|
||||
exports.plugin = {
|
||||
pkg: Package,
|
||||
register: async (server, options) => {
|
||||
|
||||
// Custom plugin code can go here
|
||||
|
||||
await HauteCouture.compose(server, options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
options: {
|
||||
migrationsDir: `${__dirname}/../migrations`
|
||||
}
|
||||
};
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
options: {
|
||||
migrationsDir: `${__dirname}/../migrations`
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
method: 'get',
|
||||
path: '/user',
|
||||
options: { },
|
||||
handler: async (request, h) => {
|
||||
|
||||
return { firstName: 'John', lastName: 'Doe'};
|
||||
}
|
||||
};
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
method: 'get',
|
||||
path: '/user',
|
||||
options: { },
|
||||
handler: async (request, h) => {
|
||||
|
||||
return { firstName: 'John', lastName: 'Doe'};
|
||||
}
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load Diff
98
package.json
98
package.json
|
@ -1,49 +1,49 @@
|
|||
{
|
||||
"name": "iut-project-cemal",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"main": "lib/index.js",
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node server",
|
||||
"test": "lab -a @hapi/code -I \"__core-js_shared__,CSS,regeneratorRuntime,core\" -L",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@hapi/boom": "9.x.x",
|
||||
"@hapipal/haute-couture": "4.x.x",
|
||||
"joi": "17.x.x",
|
||||
"objection": "2.x.x",
|
||||
"@hapipal/schwifty": "6.x.x",
|
||||
"sqlite3": "5.0.2",
|
||||
"exiting": "6.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"knex": "0.21.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/eslint-config-hapi": "13.x.x",
|
||||
"@hapi/eslint-plugin-hapi": "4.x.x",
|
||||
"@hapi/glue": "8.x.x",
|
||||
"@hapi/hapi": "20.x.x",
|
||||
"@hapi/hoek": "9.x.x",
|
||||
"@hapi/inert": "6.x.x",
|
||||
"@hapi/lab": "23.x.x",
|
||||
"@hapi/vision": "6.x.x",
|
||||
"babel-eslint": "10.x.x",
|
||||
"@hapipal/confidence": "6.x.x",
|
||||
"dotenv": "8.x.x",
|
||||
"eslint": "7.x.x",
|
||||
"hapi-swagger": "14.x.x",
|
||||
"@hapipal/hpal": "3.x.x",
|
||||
"@hapipal/hpal-debug": "2.x.x",
|
||||
"knex": "^0.21.16",
|
||||
"@hapipal/toys": "3.x.x"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "iut-project-cemal",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"main": "lib/index.js",
|
||||
"directories": {
|
||||
"lib": "lib",
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node server",
|
||||
"test": "lab -a @hapi/code -I \"__core-js_shared__,CSS,regeneratorRuntime,core\" -L",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@hapi/boom": "9.x.x",
|
||||
"@hapipal/haute-couture": "4.x.x",
|
||||
"joi": "17.x.x",
|
||||
"objection": "2.x.x",
|
||||
"@hapipal/schwifty": "6.x.x",
|
||||
"sqlite3": "5.0.2",
|
||||
"exiting": "6.0.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"knex": "0.21.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@hapi/code": "8.x.x",
|
||||
"@hapi/eslint-config-hapi": "13.x.x",
|
||||
"@hapi/eslint-plugin-hapi": "4.x.x",
|
||||
"@hapi/glue": "8.x.x",
|
||||
"@hapi/hapi": "20.x.x",
|
||||
"@hapi/hoek": "9.x.x",
|
||||
"@hapi/inert": "6.x.x",
|
||||
"@hapi/lab": "23.x.x",
|
||||
"@hapi/vision": "6.x.x",
|
||||
"babel-eslint": "10.x.x",
|
||||
"@hapipal/confidence": "6.x.x",
|
||||
"dotenv": "8.x.x",
|
||||
"eslint": "7.x.x",
|
||||
"hapi-swagger": "14.x.x",
|
||||
"@hapipal/hpal": "3.x.x",
|
||||
"@hapipal/hpal-debug": "2.x.x",
|
||||
"knex": "^0.21.16",
|
||||
"@hapipal/toys": "3.x.x"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Rename me to .env then fill me with runtime configuration and credentials
|
||||
# Just don't try to check me into your repo :)
|
||||
# Confused? See https://github.com/motdotla/dotenv
|
||||
#
|
||||
# e.g.
|
||||
# PORT=4000
|
||||
# Rename me to .env then fill me with runtime configuration and credentials
|
||||
# Just don't try to check me into your repo :)
|
||||
# Confused? See https://github.com/motdotla/dotenv
|
||||
#
|
||||
# e.g.
|
||||
# PORT=4000
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
const Glue = require('@hapi/glue');
|
||||
const Exiting = require('exiting');
|
||||
const Manifest = require('./manifest');
|
||||
|
||||
exports.deployment = async ({ start } = {}) => {
|
||||
|
||||
const manifest = Manifest.get('/', process.env);
|
||||
const server = await Glue.compose(manifest, { relativeTo: __dirname });
|
||||
|
||||
if (start) {
|
||||
await Exiting.createManager(server).start();
|
||||
server.log(['start'], `Server started at ${server.info.uri}`);
|
||||
return server;
|
||||
}
|
||||
|
||||
await server.initialize();
|
||||
|
||||
return server;
|
||||
};
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
exports.deployment({ start: true });
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
'use strict';
|
||||
|
||||
const Glue = require('@hapi/glue');
|
||||
const Exiting = require('exiting');
|
||||
const Manifest = require('./manifest');
|
||||
|
||||
exports.deployment = async ({ start } = {}) => {
|
||||
|
||||
const manifest = Manifest.get('/', process.env);
|
||||
const server = await Glue.compose(manifest, { relativeTo: __dirname });
|
||||
|
||||
if (start) {
|
||||
await Exiting.createManager(server).start();
|
||||
server.log(['start'], `Server started at ${server.info.uri}`);
|
||||
return server;
|
||||
}
|
||||
|
||||
await server.initialize();
|
||||
|
||||
return server;
|
||||
};
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
exports.deployment({ start: true });
|
||||
|
||||
process.on('unhandledRejection', (err) => {
|
||||
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,72 +1,72 @@
|
|||
'use strict';
|
||||
|
||||
const Dotenv = require('dotenv');
|
||||
const Confidence = require('@hapipal/confidence');
|
||||
const Toys = require('@hapipal/toys');
|
||||
const Schwifty = require('@hapipal/schwifty');
|
||||
|
||||
// Pull .env into process.env
|
||||
Dotenv.config({ path: `${__dirname}/.env` });
|
||||
|
||||
// Glue manifest as a confidence store
|
||||
module.exports = new Confidence.Store({
|
||||
server: {
|
||||
host: 'localhost',
|
||||
port: {
|
||||
$env: 'PORT',
|
||||
$coerce: 'number',
|
||||
$default: 3000
|
||||
},
|
||||
debug: {
|
||||
$filter: { $env: 'NODE_ENV' },
|
||||
$default: {
|
||||
log: ['error'],
|
||||
request: ['error']
|
||||
},
|
||||
production: {
|
||||
request: ['implementation']
|
||||
}
|
||||
}
|
||||
},
|
||||
register: {
|
||||
plugins: [
|
||||
{
|
||||
plugin: '../lib', // Main plugin
|
||||
options: {}
|
||||
},
|
||||
{
|
||||
plugin: './plugins/swagger'
|
||||
},
|
||||
{
|
||||
plugin: '@hapipal/schwifty',
|
||||
options: {
|
||||
$filter: 'NODE_ENV',
|
||||
$default: {},
|
||||
$base: {
|
||||
migrateOnStart: true,
|
||||
knex: {
|
||||
client: 'sqlite3',
|
||||
useNullAsDefault: true, // Suggested for sqlite3
|
||||
connection: {
|
||||
filename: ':memory:'
|
||||
},
|
||||
migrations: {
|
||||
stub: Schwifty.migrationsStubPath
|
||||
}
|
||||
}
|
||||
},
|
||||
production: {
|
||||
migrateOnStart: false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
plugin: {
|
||||
$filter: { $env: 'NODE_ENV' },
|
||||
$default: '@hapipal/hpal-debug',
|
||||
production: Toys.noop
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
'use strict';
|
||||
|
||||
const Dotenv = require('dotenv');
|
||||
const Confidence = require('@hapipal/confidence');
|
||||
const Toys = require('@hapipal/toys');
|
||||
const Schwifty = require('@hapipal/schwifty');
|
||||
|
||||
// Pull .env into process.env
|
||||
Dotenv.config({ path: `${__dirname}/.env` });
|
||||
|
||||
// Glue manifest as a confidence store
|
||||
module.exports = new Confidence.Store({
|
||||
server: {
|
||||
host: 'localhost',
|
||||
port: {
|
||||
$env: 'PORT',
|
||||
$coerce: 'number',
|
||||
$default: 3000
|
||||
},
|
||||
debug: {
|
||||
$filter: { $env: 'NODE_ENV' },
|
||||
$default: {
|
||||
log: ['error'],
|
||||
request: ['error']
|
||||
},
|
||||
production: {
|
||||
request: ['implementation']
|
||||
}
|
||||
}
|
||||
},
|
||||
register: {
|
||||
plugins: [
|
||||
{
|
||||
plugin: '../lib', // Main plugin
|
||||
options: {}
|
||||
},
|
||||
{
|
||||
plugin: './plugins/swagger'
|
||||
},
|
||||
{
|
||||
plugin: '@hapipal/schwifty',
|
||||
options: {
|
||||
$filter: 'NODE_ENV',
|
||||
$default: {},
|
||||
$base: {
|
||||
migrateOnStart: true,
|
||||
knex: {
|
||||
client: 'sqlite3',
|
||||
useNullAsDefault: true, // Suggested for sqlite3
|
||||
connection: {
|
||||
filename: ':memory:'
|
||||
},
|
||||
migrations: {
|
||||
stub: Schwifty.migrationsStubPath
|
||||
}
|
||||
}
|
||||
},
|
||||
production: {
|
||||
migrateOnStart: false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
plugin: {
|
||||
$filter: { $env: 'NODE_ENV' },
|
||||
$default: '@hapipal/hpal-debug',
|
||||
production: Toys.noop
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
const Inert = require('@hapi/inert');
|
||||
const Vision = require('@hapi/vision');
|
||||
const HapiSwagger = require('hapi-swagger');
|
||||
const Package = require('../../package.json');
|
||||
|
||||
module.exports = {
|
||||
name: 'app-swagger',
|
||||
async register(server) {
|
||||
|
||||
await server.register([
|
||||
Inert,
|
||||
Vision,
|
||||
{
|
||||
plugin: HapiSwagger,
|
||||
options: {
|
||||
info: {
|
||||
version: Package.version
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
};
|
||||
'use strict';
|
||||
|
||||
const Inert = require('@hapi/inert');
|
||||
const Vision = require('@hapi/vision');
|
||||
const HapiSwagger = require('hapi-swagger');
|
||||
const Package = require('../../package.json');
|
||||
|
||||
module.exports = {
|
||||
name: 'app-swagger',
|
||||
async register(server) {
|
||||
|
||||
await server.register([
|
||||
Inert,
|
||||
Vision,
|
||||
{
|
||||
plugin: HapiSwagger,
|
||||
options: {
|
||||
info: {
|
||||
version: Package.version
|
||||
}
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
// Load modules
|
||||
|
||||
const Code = require('@hapi/code');
|
||||
const Lab = require('@hapi/lab');
|
||||
const Server = require('../server');
|
||||
const Package = require('../package.json');
|
||||
|
||||
// Test shortcuts
|
||||
|
||||
const { describe, it } = exports.lab = Lab.script();
|
||||
const { expect } = Code;
|
||||
|
||||
describe('Deployment', () => {
|
||||
|
||||
it('registers the main plugin.', async () => {
|
||||
|
||||
const server = await Server.deployment();
|
||||
|
||||
expect(server.registrations[Package.name]).to.exist();
|
||||
});
|
||||
});
|
||||
'use strict';
|
||||
|
||||
// Load modules
|
||||
|
||||
const Code = require('@hapi/code');
|
||||
const Lab = require('@hapi/lab');
|
||||
const Server = require('../server');
|
||||
const Package = require('../package.json');
|
||||
|
||||
// Test shortcuts
|
||||
|
||||
const { describe, it } = exports.lab = Lab.script();
|
||||
const { expect } = Code;
|
||||
|
||||
describe('Deployment', () => {
|
||||
|
||||
it('registers the main plugin.', async () => {
|
||||
|
||||
const server = await Server.deployment();
|
||||
|
||||
expect(server.registrations[Package.name]).to.exist();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue