+2
-1
@@ -30,7 +30,8 @@
|
||||
"typeorm:migrations:revert": "typeorm migration:revert -d ./dist/database.config.js",
|
||||
"typeorm:schema:drop": "typeorm query -d ./dist/database.config.js 'DROP schema public cascade; CREATE schema public;'",
|
||||
"typeorm:schema:reset": "npm run typeorm:schema:drop && npm run typeorm:migrations:run",
|
||||
"sql:generate": "node ./dist/utils/sql.js",
|
||||
"sync:open-api": "node ./dist/bin/sync-open-api.js",
|
||||
"sync:sql": "node ./dist/bin/sync-sql.js",
|
||||
"email:dev": "email dev -p 3050 --dir src/emails"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.DB_URL = 'postgres://postgres:postgres@localhost:5432/immich';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { ApiModule } from 'src/app.module';
|
||||
import { useSwagger } from 'src/utils/misc';
|
||||
|
||||
const sync = async () => {
|
||||
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { preview: true });
|
||||
useSwagger(app, true);
|
||||
await app.close();
|
||||
};
|
||||
|
||||
sync()
|
||||
.then(() => {
|
||||
console.log('Done');
|
||||
process.exit(0);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
console.log('Something went wrong');
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -174,7 +174,7 @@ const patchOpenAPI = (document: OpenAPIObject) => {
|
||||
return document;
|
||||
};
|
||||
|
||||
export const useSwagger = (app: INestApplication) => {
|
||||
export const useSwagger = (app: INestApplication, force = false) => {
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Immich')
|
||||
.setDescription('Immich API')
|
||||
@@ -211,7 +211,7 @@ export const useSwagger = (app: INestApplication) => {
|
||||
|
||||
SwaggerModule.setup('doc', app, specification, customOptions);
|
||||
|
||||
if (isDev()) {
|
||||
if (isDev() || force) {
|
||||
// Generate API Documentation only in development mode
|
||||
const outputPath = path.resolve(process.cwd(), '../open-api/immich-openapi-specs.json');
|
||||
writeFileSync(outputPath, JSON.stringify(patchOpenAPI(specification), null, 2), { encoding: 'utf8' });
|
||||
|
||||
Reference in New Issue
Block a user