Skip to content

Commit

Permalink
Fix herokuapp
Browse files Browse the repository at this point in the history
  • Loading branch information
chnirt committed Jun 30, 2019
2 parents ae46faa + bb0a0b0 commit 1cd2112
Show file tree
Hide file tree
Showing 9 changed files with 1,310 additions and 195 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PORT=4000
SECRET_KEY='chnirt1803'
SECRET_KEY='chnirt1803'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled output
/dist
/documentation
/node_modules

# Logs
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
Expand Down Expand Up @@ -72,4 +72,4 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors

## License

Nest is [MIT licensed](LICENSE).
Nest is [MIT licensed](LICENSE).
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"webpack": "rm -rf dist && webpack --config webpack.config.js",
"start:webpack": "node dist/server",
"start:pm2": "pm2-runtime start ecosystem.config.js --env production",
"compodoc": "npx compodoc -p tsconfig.json -s",
"heroku-postbuild": "yarn --only=dev --no-shrinkwrap && yarn build"
},
"dependencies": {
Expand All @@ -37,6 +38,7 @@
"cache-manager": "^2.9.1",
"class-transformer": "^0.2.3",
"class-validator": "^0.9.1",
"compression": "^1.7.4",
"csurf": "^1.10.0",
"dataloader": "^1.4.0",
"dotenv": "^8.0.0",
Expand All @@ -57,6 +59,7 @@
"uuid": "^3.3.2"
},
"devDependencies": {
"@compodoc/compodoc": "^1.1.9",
"@nestjs/testing": "^6.0.0",
"@types/bcrypt": "^3.0.0",
"@types/dotenv": "^6.1.1",
Expand All @@ -77,8 +80,10 @@
"ts-node": "8.3.0",
"tsconfig-paths": "3.8.0",
"tslint": "5.18.0",
"typescript": "^3.5.2",
"wait-on": "^3.2.0",
"webpack": "^4.35.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.4",
"webpack-node-externals": "^1.7.2"
},
Expand Down
5 changes: 0 additions & 5 deletions src/config/graphql/graphql.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Module } from '@nestjs/common'
import { TypeOrmModule } from '@nestjs/typeorm'
import { User } from '../../modules/user/user.entity'
import { GraphqlService } from './graphql.service'
import { UserService } from '../../modules/user/user.service'
import { UserModule } from '../../modules/user/user.module'

@Module({
// imports: [TypeOrmModule.forFeature([User]), UserModule],
providers: [GraphqlService]
})
export class GraphqlModule {}
20 changes: 18 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,30 @@ import helmet from 'helmet'
import csurf from 'csurf'
import rateLimit from 'express-rate-limit'
import logger from 'morgan'
import compression from 'compression'
import { ValidationPipe } from './common/pipes/validation.pipe'

import { LoggerService } from '@nestjs/common'

export class MyLogger implements LoggerService {
log(message: string) {}
error(message: string, trace: string) {}
warn(message: string) {}
debug(message: string) {}
verbose(message: string) {}
}

dotenv.config()
const port = process.env.PORT || 3000
declare const module: any

async function bootstrap() {
const app = await NestFactory.create(AppModule, { cors: true, logger: false })
const app = await NestFactory.create(AppModule, {
cors: true,
logger: new MyLogger()
})

// app.use(helmet())
app.use(helmet())
// app.use(csurf())
// app.use(
// rateLimit({
Expand All @@ -34,9 +48,11 @@ async function bootstrap() {
// Variables: ${JSON.stringify(variables)}`
// })
// app.use(logger(':graphql-logger'))
app.use(compression())

app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }))
app.useGlobalPipes(new ValidationPipe())

await app.listen(port)

if (module.hot) {
Expand Down
5 changes: 4 additions & 1 deletion src/modules/user/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ export class User {
@IsNotEmpty()
status: boolean

// Relationship
// @Column(type => Dish)
// dishes: Dish[]

@CreateDateColumn({ type: 'timestamp' })
createdAt: string

@UpdateDateColumn({ type: 'timestamp' })
updatedAt: string

Expand Down
106 changes: 59 additions & 47 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const chalk = require('chalk');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const webpack = require('webpack')
const path = require('path')
const nodeExternals = require('webpack-node-externals')
const chalk = require('chalk')
const ProgressBarPlugin = require('progress-bar-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
entry: ['webpack/hot/poll?100', './src/main.ts'],
watch: true,
target: 'node',
externals: [
nodeExternals({
whitelist: ['webpack/hot/poll?100'],
}),
],
module: {
rules: [
{
test: /.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
mode: 'development',
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ProgressBarPlugin({
format:
chalk.hex('#6c5ce7')('build ') +
chalk.hex('#0984e3')('▯:bar▯ ') +
// chalk.red('▯ :bar ▯ ') +
chalk.hex('#00b894')('(:percent) ') +
// chalk.green(':percent ') +
chalk.hex('#ffeaa7')(':msg'),
// chalk.blue('( :elapsed s )')
complete: '▰',
incomplete: '▱',
clear: false,
}),
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'server.js',
},
};
entry: ['webpack/hot/poll?100', './src/main.ts'],
watch: true,
target: 'node',
externals: [
nodeExternals({
whitelist: ['webpack/hot/poll?100']
})
],
module: {
rules: [
{
test: /.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
mode: 'development',
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new ProgressBarPlugin({
format:
chalk.hex('#6c5ce7')('build ') +
chalk.hex('#0984e3')('▯:bar▯ ') +
// chalk.red('▯ :bar ▯ ') +
chalk.hex('#00b894')('(:percent) ') +
// chalk.green(':percent ') +
chalk.hex('#ffeaa7')(':msg'),
// chalk.blue('( :elapsed s )')
complete: '▰',
incomplete: '▱',
clear: false
}),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
analyzerHost: '127.0.0.1',
analyzerPort: '8888',
reportFilename: 'report.html',
openAnalyzer: true,
generateStatsFile: true,
statsFilename: 'stats.json'
})
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'server.js'
}
}
Loading

0 comments on commit 1cd2112

Please sign in to comment.