Skip to content

Commit

Permalink
add nestjs-api app skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbolikowski committed Mar 18, 2022
1 parent f06c3cd commit adeb917
Show file tree
Hide file tree
Showing 20 changed files with 726 additions and 58 deletions.
18 changes: 18 additions & 0 deletions apps/nestjs-api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
15 changes: 15 additions & 0 deletions apps/nestjs-api/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
displayName: 'nestjs-api',
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/apps/nestjs-api',
}
Empty file.
24 changes: 24 additions & 0 deletions apps/nestjs-api/src/app/app.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 nestjs-api!"', () => {
const appController = app.get<AppController>(AppController)
expect(appController.getData()).toEqual({
message: 'Welcome to nestjs-api!',
})
})
})
})
13 changes: 13 additions & 0 deletions apps/nestjs-api/src/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common'

import { AppService } from './app.service'

@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
getData() {
return this.appService.getData()
}
}
11 changes: 11 additions & 0 deletions apps/nestjs-api/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions apps/nestjs-api/src/app/app.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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 nestjs-api!"', () => {
expect(service.getData()).toEqual({ message: 'Welcome to nestjs-api!' })
})
})
})
8 changes: 8 additions & 0 deletions apps/nestjs-api/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common'

@Injectable()
export class AppService {
getData(): { message: string } {
return { message: 'Welcome to nestjs-api!' }
}
}
Empty file.
3 changes: 3 additions & 0 deletions apps/nestjs-api/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true,
}
3 changes: 3 additions & 0 deletions apps/nestjs-api/src/environments/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: false,
}
21 changes: 21 additions & 0 deletions apps/nestjs-api/src/main.ts
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 12 additions & 0 deletions apps/nestjs-api/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["node"],
"emitDecoratorMetadata": true,
"target": "es2015"
},
"exclude": ["**/*.spec.ts"],
"include": ["**/*.ts"]
}
13 changes: 13 additions & 0 deletions apps/nestjs-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
9 changes: 9 additions & 0 deletions apps/nestjs-api/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = {
'<rootDir>/libs/talent-pool/config',
'<rootDir>/libs/shared-utils',
'<rootDir>/libs/typescript-utilities',
'<rootDir>/apps/nestjs-api',
],
}
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"tags": [],
"implicitDependencies": []
},
"nestjs-api": {
"tags": []
},
"redi-connect": {
"tags": []
},
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/pickers": "3.2.6",
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/platform-express": "^7.0.0",
"@react-pdf/renderer": "2.0.15",
"@xstate/react": "^1.3.3",
"aws-sdk": "^2.418.0",
Expand Down Expand Up @@ -132,6 +135,7 @@
"react-use": "^17.2.4",
"redux": "^4.0.4",
"redux-observable": "1.2.0",
"reflect-metadata": "^0.1.13",
"regenerator-runtime": "0.13.7",
"rxjs": "^6.4.0",
"serve-favicon": "^2.0.1",
Expand All @@ -151,11 +155,15 @@
"@babel/preset-env": "7.12.13",
"@babel/preset-react": "7.12.13",
"@babel/preset-typescript": "7.12.13",
"@nestjs/schematics": "^7.0.0",
"@nestjs/testing": "^7.0.0",
"@nrwl/cli": "12.5.8",
"@nrwl/cypress": "12.5.8",
"@nrwl/eslint-plugin-nx": "12.5.8",
"@nrwl/jest": "12.5.8",
"@nrwl/linter": "12.5.8",
"@nrwl/nest": "12.5.8",
"@nrwl/node": "12.5.8",
"@nrwl/nx-cloud": "12.2.7",
"@nrwl/react": "12.5.8",
"@nrwl/storybook": "12.5.8",
Expand Down
Loading

0 comments on commit adeb917

Please sign in to comment.