Skip to content

Instantly share code, notes, and snippets.

View chnirt's full-sized avatar
🦦
On vacation

Chnirt chnirt

🦦
On vacation
View GitHub Profile
@chnirt
chnirt / main.ts
Last active June 19, 2019 07:16
NestJs
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');
@chnirt
chnirt / tsconfig.json
Last active June 17, 2019 11:05
NestJs
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
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'],
@chnirt
chnirt / user.graphql
Last active June 18, 2019 07:56
NestJs
type User {
_id: String!
username: String!
password: String!
}
input UserInput {
username: String!
password: String!
}
@chnirt
chnirt / app.module.ts
Last active June 19, 2019 03:51
NestJs
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: [
@chnirt
chnirt / user.entity.ts
Last active June 18, 2019 03:07
NestJs
import { Entity, Column, ObjectIdColumn } from 'typeorm';
@Entity()
export class User {
@ObjectIdColumn()
_id: string;
@Column()
username: string;
@Column()
password: string;
@chnirt
chnirt / user.input.ts
Last active June 19, 2019 03:50
NestJs
export class UserInput {
username: string;
password: string;
}
@chnirt
chnirt / user.module.ts
Last active June 19, 2019 03:50
NestJs
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],
})
@chnirt
chnirt / user.resolver.ts
Last active June 18, 2019 07:51
NestJs
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)
@chnirt
chnirt / user.service.ts
Last active June 19, 2019 03:49
NestJs
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(