add start script

This commit is contained in:
Jurgis Sakalauskas
2023-10-30 09:10:53 +02:00
parent f38803d60d
commit 1d7072aee0
11 changed files with 26 additions and 59 deletions
+2 -1
View File
@@ -8,9 +8,10 @@ DB_FOLDER='/mnt/hdd/videos/db'
RECENT_SEARCHES_FOLDER="/mnt/hdd/videos/recent-searches"
#actual env variables starts here
NODE_ENV=production
PORT=3000
LOG_FILE_REQUESTS_NAME="static_log.txt"
DB_FILENAME="db.db"
DB_FILENAME="db.sqlite"
RECENT_SEARCHES_LIMIT=20
PATTERNS_TO_IGNORE='["AOE1/"]' #file path patterns to ignore from video files scan, must be in json format
+2 -4
View File
@@ -10,8 +10,6 @@ RUN npm run typeorm:run-migrations
EXPOSE $PORT
# serve dev
CMD ["npm", "run", "start:dev"]
# start
CMD ["npm", "run", "start"]
#serve prod
#CMD ["npm", "run", "start"]
+1 -1
View File
@@ -9,7 +9,7 @@
"prebuild": "rimraf dist",
"build": "nest build && npm run copy-files",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start": "bash ./start.sh",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
+3 -1
View File
@@ -8,7 +8,9 @@ export class RequestLogMiddleware implements NestMiddleware {
async use(req: Request, res: Response, next: NextFunction) {
const strIP = this.extractIp(req);
this.log(strIP + ' ' + req.method + ' ' + decodeURI(req.url));
console.log(decodeURI(req.url));
if (configService.isDev()) {
console.log(decodeURI(req.url));
}
next();
}
-19
View File
@@ -1,19 +0,0 @@
import { StaticService } from './static.service';
describe('StaticService', () => {
let staticService: StaticService;
beforeEach(() => {
staticService = new StaticService();
});
describe('provideDirIndex', () => {
it('should return file/dir list of dir', async () => {
jest.spyOn(staticService, 'provideDirIndex');
process.env.STATIC_SERVE_FOLDER = 'test/Static/_test-data/StaticServe';
const result = await staticService.provideDirIndex('');
expect(result).toHaveLength(2);
});
});
});
+4
View File
@@ -38,6 +38,10 @@ export class ConfigService {
public getRecentSearchesConfig(): RecentSearchesConfig {
return this.recentSearches;
}
public isDev(): boolean {
return this.getEnv('NODE_ENV') !== 'production';
}
}
export const configService = new ConfigService();
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
if [ "$NODE_ENV" == "production" ]; then
echo "Starting app in production mode"
echo "Running prebuild"
npm run prebuild
echo "Running build"
npm run build
echo "Starting app"
npm run start:prod
else
echo "Starting app in development mode"
npm run start:dev
fi
-24
View File
@@ -1,24 +0,0 @@
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 moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
});
});
-9
View File
@@ -1,9 +0,0 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}