update migration scripts + update healthcheck + bump version

This commit is contained in:
mrjvs 2023-11-04 21:51:45 +01:00
parent b4e185d297
commit 241b1b1f47
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "backend", "name": "backend",
"version": "1.0.1", "version": "1.0.2",
"private": true, "private": true,
"homepage": "https://github.com/movie-web/backend", "homepage": "https://github.com/movie-web/backend",
"engines": { "engines": {
@ -15,7 +15,9 @@
"build:pre": "rimraf dist/", "build:pre": "rimraf dist/",
"build:compile": "tsc && tsc-alias", "build:compile": "tsc && tsc-alias",
"preinstall": "npx -y only-allow pnpm", "preinstall": "npx -y only-allow pnpm",
"migration:create": "npx -y mikro-orm migration:create" "migration:create": "npx -y mikro-orm migration:create",
"migration:up": "npx -y mikro-orm migration:up",
"migration:down": "npx -y mikro-orm migration:down"
}, },
"mikro-orm": { "mikro-orm": {
"useTsNode": true, "useTsNode": true,

View File

@ -5,13 +5,17 @@ import { makeRouter } from '@/services/router';
export const metaRouter = makeRouter((app) => { export const metaRouter = makeRouter((app) => {
app.get( app.get(
'/healthcheck', '/healthcheck',
handle(async ({ em }) => { handle(async ({ em, res }) => {
const databaseConnected = await em.config const databaseConnected = await em.config
.getDriver() .getDriver()
.getConnection() .getConnection()
.isConnected(); .isConnected();
const healthy = databaseConnected;
if (!healthy) res.status(503);
return { return {
healthy: databaseConnected, healthy,
databaseConnected, databaseConnected,
}; };
}), }),