refactor(security): core
This commit is contained in:
parent
c2a9287a52
commit
89b8aa2f6c
|
@ -1,4 +1,5 @@
|
|||
'@latus/core': {
|
||||
'@latus/core': {}
|
||||
'@latus/core/server': {
|
||||
up: [
|
||||
'@latus/db/server',
|
||||
'@latus/redis/server',
|
||||
|
|
|
@ -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}),
|
||||
},
|
||||
|
|
|
@ -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!');
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'],
|
||||
}),
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
|
|
@ -2,6 +2,6 @@ import {createReplServer} from './repl';
|
|||
|
||||
export default {
|
||||
hooks: {
|
||||
'@latus/core/up': (latus) => createReplServer(latus),
|
||||
'@latus/core/server/up': (latus) => createReplServer(latus),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user