Rename source folders
All checks were successful
forgejo/Procyon/seedling/pipeline/head This commit looks good

This commit is contained in:
Roman Jaroš 2023-10-24 20:43:21 +02:00
parent 2398a7c8c9
commit da23b80647
23 changed files with 4 additions and 4 deletions

View file

@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"outDir": "./dist",
"baseUrl": "./"
}
}

View file

@ -0,0 +1,15 @@
/** @type {import('jest').Config} */
const config = {
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: 'src',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
collectCoverageFrom: ['**/*.(t|j)s'],
coverageDirectory: '../coverage',
testEnvironment: 'node',
};
module.exports = config;

16
source/rest/nest-cli.json Normal file
View file

@ -0,0 +1,16 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true,
"plugins": [
{
"name": "@nestjs/swagger/plugin",
"options": {
"introspectComments": true
}
}
]
}
}

59
source/rest/package.json Normal file
View file

@ -0,0 +1,59 @@
{
"name": "$(appName)-rest",
"version": "0.1.0",
"description": "",
"author": "Roman Jaroš <hello@romanjaros.dev>",
"license": "ISC",
"scripts": {
"nest": "nest",
"build": "nest build",
"dev": "nest start --watch",
"dev:debug": "nest start --debug --watch",
"start": "node dist/main",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/axios": "^3.0.0",
"@nestjs/common": "^10.2.5",
"@nestjs/typeorm": "10.0.0",
"@nestjs/config": "^3.1.0",
"@nestjs/core": "^10.2.5",
"@nestjs/swagger": "7.1.11",
"@nestjs/platform-express": "^10.2.5",
"axios": "^1.5.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1",
"sqlite3": "^5.1.6"
},
"devDependencies": {
"@nestjs/cli": "10.1.17",
"@nestjs/mapped-types": "^2.0.2",
"@nestjs/schematics": "^10.0.2",
"@nestjs/testing": "^10.2.5",
"@types/express": "^4.17.17",
"@types/jest": "29.5.4",
"@types/node": "20.6.0",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^8.49.0",
"execa": "8.0.1",
"jest": "29.7.0",
"prettier": "^3.0.3",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "29.1.1",
"ts-loader": "^9.4.4",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.2.2"
}
}

View file

@ -0,0 +1,24 @@
// @ts-nocheck
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { envs } from './config';
import { HealthModule } from './common/health/health.module';
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true,
load: [envs],
}),
TypeOrmModule.forRoot({
type: 'sqlite',
database: `db.sqlite`,
entities: [],
logging: ['query'],
}),
HealthModule,
],
})
export class AppModule {}

View file

@ -0,0 +1,14 @@
// @ts-nocheck
import { HealthController } from './health.controller';
describe('AppController (e2e)', () => {
let healthController: HealthController;
beforeEach(() => {
healthController = new HealthController();
});
it('should return OK response', async () => {
expect(await healthController.status()).toEqual('OK');
});
});

View file

@ -0,0 +1,21 @@
// @ts-nocheck
import { Controller, Get, Response } from '@nestjs/common';
import { ApiResponse } from '@nestjs/swagger';
@Controller('health-check')
export class HealthController {
/**
* Health check endpoint
*/
@ApiResponse({
status: 200,
description: 'API is online',
schema: {
default: 'OK',
},
})
@Get()
status() {
return 'OK';
}
}

View file

@ -0,0 +1,8 @@
// @ts-nocheck
import { Module } from '@nestjs/common';
import { HealthController } from './health.controller';
@Module({
controllers: [HealthController],
})
export class HealthModule {}

View file

@ -0,0 +1,3 @@
export const envs = () => {
return {};
};

28
source/rest/src/main.ts Normal file
View file

@ -0,0 +1,28 @@
// @ts-nocheck
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// swagger
SwaggerModule.setup(
'api',
app,
SwaggerModule.createDocument(
app,
new DocumentBuilder()
.setTitle('$(AppName) API')
.setDescription('The $(AppName) API description.')
.setVersion('0.1.0')
.addServer('/api/v1')
.build(),
),
);
app.setGlobalPrefix('/api/v1');
await app.listen(8080);
}
bootstrap();

View file

@ -0,0 +1,26 @@
// @ts-nocheck
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from '../src/app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleRef: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleRef.createNestApplication();
await app.init();
});
it('/health-check (GET)', () => {
return request.agent(app.getHttpServer()).get('/health-check').expect(200).expect('OK');
});
afterAll(async () => {
await app.close();
});
});

View file

@ -0,0 +1,14 @@
/** @type {import('jest').Config} */
const config = {
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: '.',
testEnvironment: 'node',
testRegex: '.e2e-spec.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
moduleNameMapper: { '^uuid$': 'uuid' },
};
module.exports = config;

View file

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}