mirror of
https://github.com/sakaljurgis/kodi-api-server.git
synced 2026-07-08 20:37:41 +00:00
add start script
This commit is contained in:
+2
-1
@@ -8,9 +8,10 @@ DB_FOLDER='/mnt/hdd/videos/db'
|
|||||||
RECENT_SEARCHES_FOLDER="/mnt/hdd/videos/recent-searches"
|
RECENT_SEARCHES_FOLDER="/mnt/hdd/videos/recent-searches"
|
||||||
|
|
||||||
#actual env variables starts here
|
#actual env variables starts here
|
||||||
|
NODE_ENV=production
|
||||||
PORT=3000
|
PORT=3000
|
||||||
LOG_FILE_REQUESTS_NAME="static_log.txt"
|
LOG_FILE_REQUESTS_NAME="static_log.txt"
|
||||||
DB_FILENAME="db.db"
|
DB_FILENAME="db.sqlite"
|
||||||
RECENT_SEARCHES_LIMIT=20
|
RECENT_SEARCHES_LIMIT=20
|
||||||
PATTERNS_TO_IGNORE='["AOE1/"]' #file path patterns to ignore from video files scan, must be in json format
|
PATTERNS_TO_IGNORE='["AOE1/"]' #file path patterns to ignore from video files scan, must be in json format
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -10,8 +10,6 @@ RUN npm run typeorm:run-migrations
|
|||||||
|
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
|
|
||||||
# serve dev
|
# start
|
||||||
CMD ["npm", "run", "start:dev"]
|
CMD ["npm", "run", "start"]
|
||||||
|
|
||||||
#serve prod
|
|
||||||
#CMD ["npm", "run", "start"]
|
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
"prebuild": "rimraf dist",
|
"prebuild": "rimraf dist",
|
||||||
"build": "nest build && npm run copy-files",
|
"build": "nest build && npm run copy-files",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
"start": "nest start",
|
"start": "bash ./start.sh",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "nest start --watch",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch",
|
||||||
"start:prod": "node dist/src/main",
|
"start:prod": "node dist/src/main",
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ export class RequestLogMiddleware implements NestMiddleware {
|
|||||||
async use(req: Request, res: Response, next: NextFunction) {
|
async use(req: Request, res: Response, next: NextFunction) {
|
||||||
const strIP = this.extractIp(req);
|
const strIP = this.extractIp(req);
|
||||||
this.log(strIP + ' ' + req.method + ' ' + decodeURI(req.url));
|
this.log(strIP + ' ' + req.method + ' ' + decodeURI(req.url));
|
||||||
console.log(decodeURI(req.url));
|
if (configService.isDev()) {
|
||||||
|
console.log(decodeURI(req.url));
|
||||||
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -38,6 +38,10 @@ export class ConfigService {
|
|||||||
public getRecentSearchesConfig(): RecentSearchesConfig {
|
public getRecentSearchesConfig(): RecentSearchesConfig {
|
||||||
return this.recentSearches;
|
return this.recentSearches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isDev(): boolean {
|
||||||
|
return this.getEnv('NODE_ENV') !== 'production';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const configService = new ConfigService();
|
export const configService = new ConfigService();
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"moduleFileExtensions": ["js", "json", "ts"],
|
|
||||||
"rootDir": ".",
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"testRegex": ".e2e-spec.ts$",
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(t|j)s$": "ts-jest"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user