refactor(security): core

This commit is contained in:
cha0s 2021-01-19 11:16:12 -06:00
parent c2a9287a52
commit 89b8aa2f6c
11 changed files with 13 additions and 14 deletions

View File

@ -1,4 +1,5 @@
'@latus/core': {
'@latus/core': {}
'@latus/core/server': {
up: [
'@latus/db/server',
'@latus/redis/server',

View File

@ -2,10 +2,8 @@ export {default as appdata} from './appdata';
export default {
hooks: {
'@latus/http/plugins': (req, {config: {'@latus/core': {id}}}) => ({
'@latus/core/client': {
id,
},
'@latus/core/config': () => ({
up: [],
}),
'@latus/repl/context': (latus) => ({latus}),
},

View File

@ -7,7 +7,7 @@ process.stdout.write('Latus starting...\n');
try {
await Promise.all(latus.invokeFlat('@latus/core/starting'));
await Promise.all(latus.invokeFlat('@latus/core/started'));
await latus.invokeSequential('@latus/core/up');
await latus.invokeSequential('@latus/core/server/up');
// eslint-disable-next-line no-console
console.log('Latus up!');
}

View File

@ -31,7 +31,7 @@ export default {
},
));
},
'@latus/core/up': (latus) => {
'@latus/core/server/up': (latus) => {
const {config: {'@latus/db/server': {docker}}} = latus;
if ('production' !== NODE_ENV && docker) {
createDockerContainer(latus);

View File

@ -43,7 +43,7 @@ export default {
request: [],
trust: false,
}),
'@latus/core/up': (latus) => createHttpServer(latus),
'@latus/core/server/up': (latus) => createHttpServer(latus),
'@latus/repl/context': (latus) => ({
httpServer: latus.config['%http'],
}),

View File

@ -36,7 +36,7 @@ export default {
host: '127.0.0.1',
port: 6380,
}),
'@latus/core/up': (latus) => {
'@latus/core/server/up': (latus) => {
const {config: {'@latus/redis/server': {docker}}} = latus;
return 'production' !== NODE_ENV && docker ? createDockerContainer(latus) : undefined;
},

View File

@ -2,6 +2,6 @@ import {createReplServer} from './repl';
export default {
hooks: {
'@latus/core/up': (latus) => createReplServer(latus),
'@latus/core/server/up': (latus) => createReplServer(latus),
},
};

View File

@ -8,7 +8,7 @@ export default {
socket.connect();
socket.listen();
},
'@latus/socket/client': ({config: {'@latus/core/client': {id}}}) => ({
'@latus/socket/client': ({config: {'@latus/core': {id}}}) => ({
cors: {
origin: false,
},

View File

@ -10,7 +10,7 @@ export default {
successRedirect: '/',
failureRedirect: '/',
}),
'@latus/core/up': (latus) => {
'@latus/core/server/up': (latus) => {
passport.use(new LocalStrategy(
{usernameField: 'email'},
async (email, password, fn) => {

View File

@ -7,7 +7,7 @@ const debug = D('@latus/user/passport');
export default {
hooks: {
'@latus/core/up': (latus) => {
'@latus/core/server/up': (latus) => {
passport.serializeUser((user, fn) => fn(null, user.id));
passport.deserializeUser(async (id, fn) => {
const {User} = latus.get('%models.fromName');

View File

@ -6,7 +6,7 @@ const debug = D('@latus/user/session');
export default {
hooks: {
'@latus/core/up': (latus) => {
'@latus/core/server/up': (latus) => {
// eslint-disable-next-line no-param-reassign
latus.config['%session'] = expressSession({
resave: false,