This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NestFactory } from '@nestjs/core'; | |
import { AppModule } from './app.module'; | |
import { Logger } from '@nestjs/common'; | |
const port = process.env.PORT || 3000; | |
async function bootstrap() { | |
const app = await NestFactory.create(AppModule); | |
await app.listen(port); | |
Logger.log(`🚀 Server running on http://localhost:${port}`, 'Bootstrap'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"declaration": true, | |
"removeComments": true, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"target": "es6", | |
"sourceMap": true, | |
"outDir": "./dist", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { AppController } from './app.controller'; | |
import { AppService } from './app.service'; | |
import { GraphQLModule } from '@nestjs/graphql'; | |
import { join } from 'path'; | |
@Module({ | |
imports: [ | |
GraphQLModule.forRoot({ | |
typePaths: ['./**/*.graphql'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User { | |
_id: String! | |
username: String! | |
password: String! | |
} | |
input UserInput { | |
username: String! | |
password: String! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { AppController } from './app.controller'; | |
import { AppService } from './app.service'; | |
import { GraphQLModule } from '@nestjs/graphql'; | |
import { UserModule } from './user/user.module'; | |
import { TypeOrmModule } from '@nestjs/typeorm'; | |
import { join } from 'path'; | |
@Module({ | |
imports: [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity, Column, ObjectIdColumn } from 'typeorm'; | |
@Entity() | |
export class User { | |
@ObjectIdColumn() | |
_id: string; | |
@Column() | |
username: string; | |
@Column() | |
password: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class UserInput { | |
username: string; | |
password: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { UserResolver } from './user.resolver'; | |
import { UserService } from './user.service'; | |
import { TypeOrmModule } from '@nestjs/typeorm'; | |
import { User } from './user.entity'; | |
@Module({ | |
imports: [TypeOrmModule.forFeature([User])], | |
providers: [UserResolver, UserService], | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Resolver, Query, Mutation, Args } from '@nestjs/graphql'; | |
import { UserService } from './user.service'; | |
import { User } from './user.entity'; | |
import { UserInput } from './user.input'; | |
@Resolver('User') | |
export class UserResolver { | |
constructor(private readonly userService: UserService) {} | |
@Query(() => String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { UserInput } from './user.input'; | |
import { InjectRepository } from '@nestjs/typeorm'; | |
import { User } from './user.entity'; | |
import { MongoRepository } from 'typeorm'; | |
import * as uuid from 'uuid'; | |
@Injectable() | |
export class UserService { | |
constructor( |
OlderNewer