add project
This commit is contained in:
23
apps/api/src/index.ts
Normal file
23
apps/api/src/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import knex from 'knex';
|
||||
import knexConfig from './db/knexfile';
|
||||
import app from './app';
|
||||
import { env } from './config/env';
|
||||
|
||||
async function main() {
|
||||
const db = knex(knexConfig);
|
||||
|
||||
console.log('[API] Running migrations...');
|
||||
await db.migrate.latest();
|
||||
console.log('[API] Migrations complete.');
|
||||
|
||||
await db.destroy();
|
||||
|
||||
app.listen(env.port, () => {
|
||||
console.log(`[API] Server running on port ${env.port}`);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('[API] Failed to start:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user