Skip to content

Commit

Permalink
feat: --skip-next flag to skip loading nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
diced committed Dec 13, 2024
1 parent cf3c92e commit dcb6b28
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ BigInt.prototype.toJSON = function () {
};

async function main() {
logger.info('starting zipline', { mode: MODE, version: version });
const argv = process.argv.slice(2);
logger.info('starting zipline', { mode: MODE, version: version, argv });
logger.info('reading settings...');
await reloadSettings();

Expand Down Expand Up @@ -141,19 +142,20 @@ async function main() {
server.get(config.urls.route === '/' ? '/:id' : `${config.urls.route}/:id`, urlsRoute);
}

await server.register(next, {
dev: MODE === 'development',
quiet: MODE === 'production',
hostname: config.core.hostname,
port: config.core.port,
dir: '.',
});
if (!argv.includes('--skip-next'))
await server.register(next, {
dev: MODE === 'development',
quiet: MODE === 'production',
hostname: config.core.hostname,
port: config.core.port,
dir: '.',
});

const routes = await loadRoutes();
const routesOptions = Object.values(routes);
Promise.all(routesOptions.map((route) => server.register(route)));

server.next('/*', ALL_METHODS);
if (!argv.includes('--skip-next')) server.next('/*', ALL_METHODS);
server.get('/', (_, res) => res.redirect('/dashboard'));

// TODO: no longer need this when all the api routes are handled by fastify :)
Expand Down

0 comments on commit dcb6b28

Please sign in to comment.