Skip to content

Instantly share code, notes, and snippets.

View Joe1220's full-sized avatar

Joe1220

View GitHub Profile
const tsConfigPathFile = require("./tsconfig.paths.json")
const tsConfig = require("./tsconfig.json")
const tsConfigPaths = require("tsconfig-paths")
tsConfigPaths.register({
baseUrl: tsConfig.compilerOptions.outDir,
paths: tsConfigPathFile.compilerOptions.paths
})
@Joe1220
Joe1220 / package.json
Last active June 10, 2020 13:21
script version 1
"scripts": {
"dev": "nodemon --exec ts-node -r tsconfig-paths/register src/index.ts",
"build": "tsc -p tsconfig.json",
"prestart": "rm -rf ./dist && yarn build",
"start": "node dist/index.js"
}
@Joe1220
Joe1220 / tsconfig.json
Created June 10, 2020 09:10
edit outdir tsconfig.json
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"module": "Commonjs",
"target": "es5",
"sourceMap": true,
"allowJs": true,
"outDir": "./dist"
},
"exclude": ["node_modules"]
@Joe1220
Joe1220 / tsconfig.json
Created June 10, 2020 09:05
extend paths.json
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"module": "Commonjs",
"target": "es5",
"sourceMap": true,
"allowJs": true
},
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"src/*": ["src/*"]
}
}
}
@Joe1220
Joe1220 / index.ts
Created June 9, 2020 17:18
ts-absolute-test absolute path
import { TEST_TEXT } from "src/constants"
console.log("hello world", TEST_TEXT)
@Joe1220
Joe1220 / tsconfig.json
Created June 9, 2020 17:13
ts-absolute version 1
{
"compilerOptions": {
"module": "Commonjs",
"target": "es5",
"sourceMap": true,
"allowJs": true,
"baseUrl": ".",
"paths": {
"src/*": ["src/*"]
}
@Joe1220
Joe1220 / index.ts
Created June 9, 2020 16:32
for ts-absolute-test
import { TEST_TEXT } from "./constants"
console.log("hello world", TEST_TEXT)
@Joe1220
Joe1220 / constants.ts
Created June 9, 2020 16:31
test test
import { TEST_TEXT } from "./constants"
console.log("hello world", TEST_TEXT)
@Joe1220
Joe1220 / server.ts
Created June 7, 2020 14:38
make graphql-yoga server
import { GraphQLServer } from "graphql-yoga"
import logger from "morgan"
import cors from "cors"
import helmet from "helmet"
const createServer = async () => {
const server = new GraphQLServer({})
// middleware 추가
server.express.use(logger("dev"))
server.express.use(cors())