initial commit

This commit is contained in:
2021-07-30 17:16:47 -04:00
parent c407fb2fc8
commit 1a9afdc2b8
73 changed files with 46988 additions and 0 deletions
View File
+22
View File
@@ -0,0 +1,22 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let app: TestingModule;
beforeAll(async () => {
app = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
});
describe('getData', () => {
it('should return "Welcome to api!"', () => {
const appController = app.get<AppController>(AppController);
expect(appController.getData()).toEqual({ message: 'Welcome to api!' });
});
});
});
+15
View File
@@ -0,0 +1,15 @@
import { Controller, Get } from '@nestjs/common';
import { Message } from '@vidgrab2/api-interfaces';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get('hello')
getData(): Message {
return this.appService.getData();
}
}
+11
View File
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
+21
View File
@@ -0,0 +1,21 @@
import { Test } from '@nestjs/testing';
import { AppService } from './app.service';
describe('AppService', () => {
let service: AppService;
beforeAll(async () => {
const app = await Test.createTestingModule({
providers: [AppService],
}).compile();
service = app.get<AppService>(AppService);
});
describe('getData', () => {
it('should return "Welcome to api!"', () => {
expect(service.getData()).toEqual({ message: 'Welcome to api!' });
});
});
});
+9
View File
@@ -0,0 +1,9 @@
import { Injectable } from '@nestjs/common';
import { Message } from '@vidgrab2/api-interfaces';
@Injectable()
export class AppService {
getData(): Message {
return { message: 'Welcome to api!' };
}
}
View File
@@ -0,0 +1,3 @@
export const environment = {
production: true,
};
+3
View File
@@ -0,0 +1,3 @@
export const environment = {
production: false,
};
+21
View File
@@ -0,0 +1,21 @@
/**
* This is not a production server yet!
* This is only a minimal backend to get started.
*/
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app/app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const globalPrefix = 'api';
app.setGlobalPrefix(globalPrefix);
const port = process.env.PORT || 3333;
await app.listen(port, () => {
Logger.log('Listening at http://localhost:' + port + '/' + globalPrefix);
});
}
bootstrap();