mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 03:29:02 +01:00 
			
		
		
		
	converted of web (non-api) routes, basic conversion completed
This commit is contained in:
		
							parent
							
								
									cfe0ae1eda
								
							
						
					
					
						commit
						795d50f02e
					
				| @ -1,12 +1,7 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); |  | ||||||
| const router = express.Router(); |  | ||||||
| const sql = require('../../services/sql'); | const sql = require('../../services/sql'); | ||||||
| const auth = require('../../services/auth'); |  | ||||||
| const image = require('../../services/image'); | const image = require('../../services/image'); | ||||||
| const multer = require('multer')(); |  | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR; | const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR; | ||||||
| const fs = require('fs'); | const fs = require('fs'); | ||||||
| 
 | 
 | ||||||
| @ -14,7 +9,7 @@ async function returnImage(req, res) { | |||||||
|     const image = await sql.getRow("SELECT * FROM images WHERE imageId = ?", [req.params.imageId]); |     const image = await sql.getRow("SELECT * FROM images WHERE imageId = ?", [req.params.imageId]); | ||||||
| 
 | 
 | ||||||
|     if (!image) { |     if (!image) { | ||||||
|         return res.status(404).send({}); |         return res.sendStatus(404); | ||||||
|     } |     } | ||||||
|     else if (image.data === null) { |     else if (image.data === null) { | ||||||
|         res.set('Content-Type', 'image/png'); |         res.set('Content-Type', 'image/png'); | ||||||
| @ -26,7 +21,7 @@ async function returnImage(req, res) { | |||||||
|     res.send(image.data); |     res.send(image.data); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function uploadImage(req, res) { | async function uploadImage(req) { | ||||||
|     const sourceId = req.headers.source_id; |     const sourceId = req.headers.source_id; | ||||||
|     const noteId = req.query.noteId; |     const noteId = req.query.noteId; | ||||||
|     const file = req.file; |     const file = req.file; | ||||||
| @ -34,19 +29,19 @@ async function uploadImage(req, res) { | |||||||
|     const note = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]); |     const note = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]); | ||||||
| 
 | 
 | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return res.status(404).send(`Note ${noteId} doesn't exist.`); |         return [404, `Note ${noteId} doesn't exist.`]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (!["image/png", "image/jpeg", "image/gif"].includes(file.mimetype)) { |     if (!["image/png", "image/jpeg", "image/gif"].includes(file.mimetype)) { | ||||||
|         return res.status(400).send("Unknown image type: " + file.mimetype); |         return [400, "Unknown image type: " + file.mimetype]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const {fileName, imageId} = await image.saveImage(file, sourceId, noteId); |     const {fileName, imageId} = await image.saveImage(file, sourceId, noteId); | ||||||
| 
 | 
 | ||||||
|     res.send({ |     return { | ||||||
|         uploaded: true, |         uploaded: true, | ||||||
|         url: `/api/images/${imageId}/${fileName}` |         url: `/api/images/${imageId}/${fileName}` | ||||||
|     }); |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
|  | |||||||
| @ -90,7 +90,7 @@ async function parseImportFile(file) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function importTar(req, res) { | async function importTar(req) { | ||||||
|     const sourceId = req.headers.source_id; |     const sourceId = req.headers.source_id; | ||||||
|     const parentNoteId = req.params.parentNoteId; |     const parentNoteId = req.params.parentNoteId; | ||||||
|     const file = req.file; |     const file = req.file; | ||||||
| @ -98,14 +98,12 @@ async function importTar(req, res) { | |||||||
|     const note = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [parentNoteId]); |     const note = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [parentNoteId]); | ||||||
| 
 | 
 | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return res.status(404).send(`Note ${parentNoteId} doesn't exist.`); |         return [404, `Note ${parentNoteId} doesn't exist.`]; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const files = await parseImportFile(file); |     const files = await parseImportFile(file); | ||||||
| 
 | 
 | ||||||
|     await importNotes(files, parentNoteId, sourceId); |     await importNotes(files, parentNoteId, sourceId); | ||||||
| 
 |  | ||||||
|     res.send({}); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function importNotes(files, parentNoteId, sourceId) { | async function importNotes(files, parentNoteId, sourceId) { | ||||||
|  | |||||||
| @ -1,17 +1,13 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); |  | ||||||
| const router = express.Router(); |  | ||||||
| const options = require('../../services/options'); | const options = require('../../services/options'); | ||||||
| const utils = require('../../services/utils'); | const utils = require('../../services/utils'); | ||||||
| const source_id = require('../../services/source_id'); | const source_id = require('../../services/source_id'); | ||||||
| const auth = require('../../services/auth'); |  | ||||||
| const password_encryption = require('../../services/password_encryption'); | const password_encryption = require('../../services/password_encryption'); | ||||||
| const protected_session = require('../../services/protected_session'); | const protected_session = require('../../services/protected_session'); | ||||||
| const app_info = require('../../services/app_info'); | const app_info = require('../../services/app_info'); | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 | 
 | ||||||
| router.post('/sync', wrap(async (req, res, next) => { | async function loginSync(req) { | ||||||
|     const timestampStr = req.body.timestamp; |     const timestampStr = req.body.timestamp; | ||||||
| 
 | 
 | ||||||
|     const timestamp = utils.parseDateTime(timestampStr); |     const timestamp = utils.parseDateTime(timestampStr); | ||||||
| @ -19,15 +15,13 @@ router.post('/sync', wrap(async (req, res, next) => { | |||||||
|     const now = new Date(); |     const now = new Date(); | ||||||
| 
 | 
 | ||||||
|     if (Math.abs(timestamp.getTime() - now.getTime()) > 5000) { |     if (Math.abs(timestamp.getTime() - now.getTime()) > 5000) { | ||||||
|         res.status(400); |         return [400, { message: 'Auth request time is out of sync' }]; | ||||||
|         res.send({ message: 'Auth request time is out of sync' }); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const dbVersion = req.body.dbVersion; |     const dbVersion = req.body.dbVersion; | ||||||
| 
 | 
 | ||||||
|     if (dbVersion !== app_info.db_version) { |     if (dbVersion !== app_info.db_version) { | ||||||
|         res.status(400); |         return [400, { message: 'Non-matching db versions, local is version ' + app_info.db_version }]; | ||||||
|         res.send({ message: 'Non-matching db versions, local is version ' + app_info.db_version }); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const documentSecret = await options.getOption('document_secret'); |     const documentSecret = await options.getOption('document_secret'); | ||||||
| @ -36,38 +30,37 @@ router.post('/sync', wrap(async (req, res, next) => { | |||||||
|     const givenHash = req.body.hash; |     const givenHash = req.body.hash; | ||||||
| 
 | 
 | ||||||
|     if (expectedHash !== givenHash) { |     if (expectedHash !== givenHash) { | ||||||
|         res.status(400); |         return [400, { message: "Sync login hash doesn't match" }]; | ||||||
|         res.send({ message: "Sync login hash doesn't match" }); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     req.session.loggedIn = true; |     req.session.loggedIn = true; | ||||||
| 
 | 
 | ||||||
|     res.send({ |     return { | ||||||
|         sourceId: source_id.getCurrentSourceId() |         sourceId: source_id.getCurrentSourceId() | ||||||
|     }); |     }; | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| // this is for entering protected mode so user has to be already logged-in (that's the reason we don't require username)
 | async function loginToProtectedSession(req) { | ||||||
| router.post('/protected', auth.checkApiAuth, wrap(async (req, res, next) => { |  | ||||||
|     const password = req.body.password; |     const password = req.body.password; | ||||||
| 
 | 
 | ||||||
|     if (!await password_encryption.verifyPassword(password)) { |     if (!await password_encryption.verifyPassword(password)) { | ||||||
|         res.send({ |         return { | ||||||
|             success: false, |             success: false, | ||||||
|             message: "Given current password doesn't match hash" |             message: "Given current password doesn't match hash" | ||||||
|         }); |         }; | ||||||
| 
 |  | ||||||
|         return; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const decryptedDataKey = await password_encryption.getDataKey(password); |     const decryptedDataKey = await password_encryption.getDataKey(password); | ||||||
| 
 | 
 | ||||||
|     const protectedSessionId = protected_session.setDataKey(req, decryptedDataKey); |     const protectedSessionId = protected_session.setDataKey(req, decryptedDataKey); | ||||||
| 
 | 
 | ||||||
|     res.send({ |     return { | ||||||
|         success: true, |         success: true, | ||||||
|         protectedSessionId: protectedSessionId |         protectedSessionId: protectedSessionId | ||||||
|     }); |     }; | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| module.exports = router; | module.exports = { | ||||||
|  |     loginSync, | ||||||
|  |     loginToProtectedSession | ||||||
|  | }; | ||||||
| @ -1,26 +1,25 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); |  | ||||||
| const router = express.Router(); |  | ||||||
| const auth = require('../../services/auth'); |  | ||||||
| const options = require('../../services/options'); | const options = require('../../services/options'); | ||||||
| const migration = require('../../services/migration'); | const migration = require('../../services/migration'); | ||||||
| const app_info = require('../../services/app_info'); | const app_info = require('../../services/app_info'); | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 | 
 | ||||||
| router.get('', auth.checkApiAuthForMigrationPage, wrap(async (req, res, next) => { | async function getMigrationInfo() { | ||||||
|     res.send({ |     return { | ||||||
|         db_version: parseInt(await options.getOption('db_version')), |         db_version: parseInt(await options.getOption('db_version')), | ||||||
|         app_db_version: app_info.db_version |         app_db_version: app_info.db_version | ||||||
|     }); |     }; | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| router.post('', auth.checkApiAuthForMigrationPage, wrap(async (req, res, next) => { | async function executeMigration() { | ||||||
|     const migrations = await migration.migrate(); |     const migrations = await migration.migrate(); | ||||||
| 
 | 
 | ||||||
|     res.send({ |     return { | ||||||
|         migrations: migrations |         migrations: migrations | ||||||
|     }); |     }; | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| module.exports = router; | module.exports = { | ||||||
|  |     getMigrationInfo, | ||||||
|  |     executeMigration | ||||||
|  | }; | ||||||
| @ -1,15 +1,11 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); |  | ||||||
| const router = express.Router(); |  | ||||||
| const auth = require('../services/auth'); |  | ||||||
| const source_id = require('../services/source_id'); | const source_id = require('../services/source_id'); | ||||||
| const sql = require('../services/sql'); | const sql = require('../services/sql'); | ||||||
| const Repository = require('../services/repository'); | const Repository = require('../services/repository'); | ||||||
| const labels = require('../services/labels'); | const labels = require('../services/labels'); | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 | 
 | ||||||
| router.get('', auth.checkAuth, wrap(async (req, res, next) => { | async function index(req, res) { | ||||||
|     const repository = new Repository(req); |     const repository = new Repository(req); | ||||||
| 
 | 
 | ||||||
|     res.render('index', { |     res.render('index', { | ||||||
| @ -17,7 +13,7 @@ router.get('', auth.checkAuth, wrap(async (req, res, next) => { | |||||||
|         maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"), |         maxSyncIdAtLoad: await sql.getValue("SELECT MAX(id) FROM sync"), | ||||||
|         appCss: await getAppCss(repository) |         appCss: await getAppCss(repository) | ||||||
|     }); |     }); | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| async function getAppCss(repository) { | async function getAppCss(repository) { | ||||||
|     let css = ''; |     let css = ''; | ||||||
| @ -33,4 +29,6 @@ ${note.content} | |||||||
|     return css; |     return css; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = router; | module.exports = { | ||||||
|  |     index | ||||||
|  | }; | ||||||
|  | |||||||
| @ -1,17 +1,14 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); |  | ||||||
| const router = express.Router(); |  | ||||||
| const utils = require('../services/utils'); | const utils = require('../services/utils'); | ||||||
| const options = require('../services/options'); | const options = require('../services/options'); | ||||||
| const my_scrypt = require('../services/my_scrypt'); | const my_scrypt = require('../services/my_scrypt'); | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 | 
 | ||||||
| router.get('', wrap(async (req, res, next) => { | function loginPage(req, res) { | ||||||
|     res.render('login', { 'failedAuth': false }); |     res.render('login', { failedAuth: false }); | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| router.post('', wrap(async (req, res, next) => { | async function login(req, res) { | ||||||
|     const userName = await options.getOption('username'); |     const userName = await options.getOption('username'); | ||||||
| 
 | 
 | ||||||
|     const guessedPassword = req.body.password; |     const guessedPassword = req.body.password; | ||||||
| @ -33,15 +30,27 @@ router.post('', wrap(async (req, res, next) => { | |||||||
|     else { |     else { | ||||||
|         res.render('login', {'failedAuth': true}); |         res.render('login', {'failedAuth': true}); | ||||||
|     } |     } | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| 
 | async function verifyPassword(guessedPassword) { | ||||||
| async function verifyPassword(guessed_password) { |  | ||||||
|     const hashed_password = utils.fromBase64(await options.getOption('password_verification_hash')); |     const hashed_password = utils.fromBase64(await options.getOption('password_verification_hash')); | ||||||
| 
 | 
 | ||||||
|     const guess_hashed = await my_scrypt.getVerificationHash(guessed_password); |     const guess_hashed = await my_scrypt.getVerificationHash(guessedPassword); | ||||||
| 
 | 
 | ||||||
|     return guess_hashed.equals(hashed_password); |     return guess_hashed.equals(hashed_password); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = router; | function logout(req, res) { | ||||||
|  |     req.session.regenerate(() => { | ||||||
|  |         req.session.loggedIn = false; | ||||||
|  | 
 | ||||||
|  |         res.redirect('/'); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | module.exports = { | ||||||
|  |     loginPage, | ||||||
|  |     login, | ||||||
|  |     logout | ||||||
|  | }; | ||||||
|  | |||||||
| @ -1,16 +0,0 @@ | |||||||
| "use strict"; |  | ||||||
| 
 |  | ||||||
| const express = require('express'); |  | ||||||
| const router = express.Router(); |  | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 |  | ||||||
| router.post('', wrap(async (req, res, next) => { |  | ||||||
|     req.session.regenerate(() => { |  | ||||||
|         req.session.loggedIn = false; |  | ||||||
| 
 |  | ||||||
|         res.redirect('/'); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
| })); |  | ||||||
| 
 |  | ||||||
| module.exports = router; |  | ||||||
| @ -1,12 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); | function migrationPage(req, res) { | ||||||
| const router = express.Router(); |  | ||||||
| const auth = require('../services/auth'); |  | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 |  | ||||||
| router.get('', auth.checkAuthForMigrationPage, wrap(async (req, res, next) => { |  | ||||||
|     res.render('migration', {}); |     res.render('migration', {}); | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| module.exports = router; | module.exports = { | ||||||
|  |     migrationPage | ||||||
|  | }; | ||||||
|  | |||||||
| @ -1,6 +1,5 @@ | |||||||
| const indexRoute = require('./index'); | const indexRoute = require('./index'); | ||||||
| const loginRoute = require('./login'); | const loginRoute = require('./login'); | ||||||
| const logoutRoute = require('./logout'); |  | ||||||
| const migrationRoute = require('./migration'); | const migrationRoute = require('./migration'); | ||||||
| const setupRoute = require('./setup'); | const setupRoute = require('./setup'); | ||||||
| const multer = require('multer')(); | const multer = require('multer')(); | ||||||
| @ -63,11 +62,6 @@ function apiRoute(method, path, routeHandler) { | |||||||
|     route(method, path, [auth.checkApiAuth], routeHandler, apiResultHandler); |     route(method, path, [auth.checkApiAuth], routeHandler, apiResultHandler); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // API routes requiring HTTP protocol. This means we ignore route return value and make an electron auth exception
 |  | ||||||
| function httpApiRoute(method, path, routeHandler) { |  | ||||||
|     route(method, path, [auth.checkApiAuth, multer.single('upload')], routeHandler); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| function route(method, path, middleware, routeHandler, resultHandler) { | function route(method, path, middleware, routeHandler, resultHandler) { | ||||||
|     router[method](path, ...middleware, async (req, res, next) => { |     router[method](path, ...middleware, async (req, res, next) => { | ||||||
|         try { |         try { | ||||||
| @ -95,11 +89,12 @@ const GET = 'get', POST = 'post', PUT = 'put', DELETE = 'delete'; | |||||||
| const uploadMiddleware = multer.single('upload'); | const uploadMiddleware = multer.single('upload'); | ||||||
| 
 | 
 | ||||||
| function register(app) { | function register(app) { | ||||||
|     app.use('/', indexRoute); |     route(GET, '/', [auth.checkAuth], indexRoute.index); | ||||||
|     app.use('/login', loginRoute); |     route(GET, '/login', [], loginRoute.loginPage); | ||||||
|     app.use('/logout', logoutRoute); |     route(POST, '/login', [], loginRoute.login); | ||||||
|     app.use('/migration', migrationRoute); |     route(POST, '/logout', [auth.checkAuth], loginRoute.logout); | ||||||
|     app.use('/setup', setupRoute); |     route(GET, '/migration', [auth.checkAuthForMigrationPage], migrationRoute.migrationPage); | ||||||
|  |     route(GET, '/setup', [auth.checkAppNotInitialized], setupRoute.setupPage); | ||||||
| 
 | 
 | ||||||
|     apiRoute(GET, '/api/tree', treeApiRoute.getTree); |     apiRoute(GET, '/api/tree', treeApiRoute.getTree); | ||||||
|     apiRoute(PUT, '/api/tree/:branchId/set-prefix', treeApiRoute.setPrefix); |     apiRoute(PUT, '/api/tree/:branchId/set-prefix', treeApiRoute.setPrefix); | ||||||
| @ -167,8 +162,8 @@ function register(app) { | |||||||
|     apiRoute(PUT, '/api/recent-notes/:branchId/:notePath', recentNotesRoute.addRecentNote); |     apiRoute(PUT, '/api/recent-notes/:branchId/:notePath', recentNotesRoute.addRecentNote); | ||||||
|     apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo); |     apiRoute(GET, '/api/app-info', appInfoRoute.getAppInfo); | ||||||
| 
 | 
 | ||||||
|     httpApiRoute(GET, '/api/export/:noteId', exportRoute.exportNote); |     route(GET, '/api/export/:noteId', [auth.checkApiAuthOrElectron], exportRoute.exportNote); | ||||||
|     httpApiRoute(POST, '/api/import/:parentNoteId', importRoute.importTar); |     route(POST, '/api/import/:parentNoteId', [auth.checkApiAuthOrElectron], importRoute.importTar, apiResultHandler); | ||||||
| 
 | 
 | ||||||
|     route(POST, '/api/setup', [auth.checkAppNotInitialized], setupApiRoute.setup, apiResultHandler); |     route(POST, '/api/setup', [auth.checkAppNotInitialized], setupApiRoute.setup, apiResultHandler); | ||||||
| 
 | 
 | ||||||
| @ -179,8 +174,8 @@ function register(app) { | |||||||
|     apiRoute(POST, '/api/cleanup/cleanup-unused-images', cleanupRoute.cleanupUnusedImages); |     apiRoute(POST, '/api/cleanup/cleanup-unused-images', cleanupRoute.cleanupUnusedImages); | ||||||
|     apiRoute(POST, '/api/cleanup/vacuum-database', cleanupRoute.vacuumDatabase); |     apiRoute(POST, '/api/cleanup/vacuum-database', cleanupRoute.vacuumDatabase); | ||||||
| 
 | 
 | ||||||
|     httpApiRoute(GET, '/api/images/:imageId/:filename', imageRoute.returnImage); |     route(GET, '/api/images/:imageId/:filename', [auth.checkApiAuthOrElectron], imageRoute.returnImage); | ||||||
|     httpApiRoute(POST, '/api/images', imageRoute.uploadImage); |     route(POST, '/api/images', [auth.checkApiAuthOrElectron], imageRoute.uploadImage, apiResultHandler); | ||||||
| 
 | 
 | ||||||
|     apiRoute(POST, '/api/script/exec', scriptRoute.exec); |     apiRoute(POST, '/api/script/exec', scriptRoute.exec); | ||||||
|     apiRoute(POST, '/api/script/run/:noteId', scriptRoute.run); |     apiRoute(POST, '/api/script/run/:noteId', scriptRoute.run); | ||||||
| @ -199,11 +194,14 @@ function register(app) { | |||||||
|     apiRoute(GET, '/api/search/:searchString', searchRoute.searchNotes); |     apiRoute(GET, '/api/search/:searchString', searchRoute.searchNotes); | ||||||
|     apiRoute(POST, '/api/search/:searchString', searchRoute.saveSearchToNote); |     apiRoute(POST, '/api/search/:searchString', searchRoute.saveSearchToNote); | ||||||
| 
 | 
 | ||||||
|  |     route(GET, '/api/migration', [auth.checkApiAuthForMigrationPage], migrationApiRoute.getMigrationInfo, apiResultHandler); | ||||||
|  |     route(POST, '/api/migration', [auth.checkApiAuthForMigrationPage], migrationApiRoute.executeMigration, apiResultHandler); | ||||||
|  | 
 | ||||||
|  |     route(POST, '/api/login/sync', [], loginApiRoute.loginSync, apiResultHandler); | ||||||
|  |     // this is for entering protected mode so user has to be already logged-in (that's the reason we don't require username)
 | ||||||
|  |     apiRoute(POST, '/api/login/protected', loginApiRoute.loginToProtectedSession); | ||||||
|  | 
 | ||||||
|     app.use('', router); |     app.use('', router); | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     app.use('/api/migration', migrationApiRoute); |  | ||||||
|     app.use('/api/login', loginApiRoute); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { | module.exports = { | ||||||
|  | |||||||
| @ -1,12 +1,9 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const express = require('express'); | function setupPage(req, res) { | ||||||
| const router = express.Router(); |  | ||||||
| const auth = require('../services/auth'); |  | ||||||
| const wrap = require('express-promise-wrap').wrap; |  | ||||||
| 
 |  | ||||||
| router.get('', auth.checkAppNotInitialized, wrap(async (req, res, next) => { |  | ||||||
|     res.render('setup', {}); |     res.render('setup', {}); | ||||||
| })); | } | ||||||
| 
 | 
 | ||||||
| module.exports = router; | module.exports = { | ||||||
|  |     setupPage | ||||||
|  | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner