style: Format boilerplate

This commit is contained in:
Tibo De Peuter 2025-02-20 14:18:32 +01:00
parent 9b52b43f65
commit 788e1642d1
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
26 changed files with 686 additions and 564 deletions

View file

@ -1,21 +1,22 @@
import express, {Express, Request, Response} from 'express';
import initORM from './orm'
import express, { Express, Response } from 'express';
import initORM from './orm.js';
const app: Express = express();
const port: string | number = process.env.PORT || 3000;
// TODO Replace with Express routes
app.get('/', (_, res: Response) => {
res.json({
message: 'Hello Dwengo!'
});
res.json({
message: 'Hello Dwengo!',
});
});
async function startServer() {
const orm = await initORM();
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
await initORM();
app.listen(port, () => {
console.log(`Server is running at http://localhost:${port}`);
});
}
startServer();

View file

@ -1,13 +1,13 @@
import { Entity, OneToOne, PrimaryKey, Property } from '@mikro-orm/core'
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
@Entity()
export class User {
@PrimaryKey({ type: 'number' })
id!: number;
@PrimaryKey({ type: 'number' })
id!: number;
@Property()
firstName: string = '';
@Property()
firstName: string = '';
@Property()
lastName: string = '';
}
@Property()
lastName: string = '';
}

View file

@ -1,12 +1,12 @@
import { Options } from '@mikro-orm/core'
import { PostgreSqlDriver } from '@mikro-orm/postgresql'
import { Options } from '@mikro-orm/core';
import { PostgreSqlDriver } from '@mikro-orm/postgresql';
const config: Options = {
driver: PostgreSqlDriver,
dbName: 'dwengo',
entities: ['dist/**/*.entity.js'],
entitiesTs: ['src/**/*.entity.ts'],
debug: true
driver: PostgreSqlDriver,
dbName: 'dwengo',
entities: ['dist/**/*.entity.js'],
entitiesTs: ['src/**/*.entity.ts'],
debug: true,
};
export default config;

View file

@ -1,6 +1,6 @@
import { MikroORM } from '@mikro-orm/core'
import config from './mikro-orm.config';
import { MikroORM } from '@mikro-orm/core';
import config from './mikro-orm.config.js';
export default async function initORM() {
await MikroORM.init(config);
await MikroORM.init(config);
}