Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f34ee5d
Showing
16 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
"next/babel", | ||
"@zeit/next-typescript/babel" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
.next/ | ||
package-lock.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const withTs = require('@zeit/next-typescript'); | ||
module.exports = withTs(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"ignore": [ | ||
"**/*.test.ts", | ||
"**/*.spec.ts", | ||
".git", | ||
"node_modules", | ||
".next" | ||
], | ||
"watch": [ | ||
"server", | ||
"types" | ||
], | ||
"exec": "npm run dev", | ||
"ext": "ts" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "ydb", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"tsc": "tsc", | ||
"dev": "ts-node --files ./server/index.ts", | ||
"nodemon": "./node_modules/nodemon/bin/nodemon.js", | ||
"lint:ts": "tslint -c tslint.json 'src/**/*.ts*'", | ||
"pretty": "prettier --write client/**/*.ts* server/**/*.ts" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@types/express-graphql": "^0.6.2", | ||
"@types/graphql": "^14.2.0", | ||
"@types/morgan": "^1.7.35", | ||
"@zeit/next-typescript": "^1.1.1", | ||
"express": "^4.16.4", | ||
"express-graphql": "^0.8.0", | ||
"express-router-async": "^0.3.0", | ||
"graphql": "^14.2.1", | ||
"morgan": "^1.9.1", | ||
"next": "^8.1.0", | ||
"nodemon": "^1.18.11", | ||
"react": "^16.8.6", | ||
"react-dom": "^16.8.6", | ||
"ts-node": "^8.1.0", | ||
"typescript": "^3.4.4" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.16.1", | ||
"@types/next": "^8.0.3", | ||
"husky": "^1.3.1", | ||
"lint-staged": "^8.1.5", | ||
"prettier": "^1.17.0", | ||
"tslint": "^5.16.0", | ||
"tslint-config-prettier": "^1.18.0" | ||
}, | ||
"lint-staged": { | ||
"*.ts*": [ | ||
"npm run pretty", | ||
"git add" | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as React from 'react'; | ||
|
||
export default () => <h1>o no error</h1> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as React from 'react'; | ||
|
||
export default () => <h1>i home!</h1> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as React from 'react'; | ||
|
||
export default () => <h1>hi</h1> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { GraphQLSchema, GraphQLObjectType } from 'graphql'; | ||
|
||
const schema = new GraphQLSchema({ | ||
query: new GraphQLObjectType({ | ||
name: 'RootQueries', | ||
description: 'Top level queries', | ||
fields: () => ({}), | ||
}), | ||
mutation: new GraphQLObjectType({ | ||
name: 'RootMutations', | ||
description: 'Top level mutations', | ||
fields: () => ({}), | ||
}), | ||
}); | ||
|
||
export default schema; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as express from 'express'; | ||
import * as morgan from 'morgan'; | ||
import nextjs from './lib/next'; | ||
import PagesRouter from './routers/pages'; | ||
import GraphqlRouter from './routers/graphql'; | ||
|
||
const app: express.Application = express(); | ||
|
||
nextjs.nextApp.prepare().then(() => { | ||
const port = process.env.SERVER_PORT || 8080; | ||
|
||
app.use(morgan(':method :url :status')); | ||
|
||
app.use(PagesRouter); | ||
app.use(GraphqlRouter); | ||
|
||
app.get('*', (req, res) => { | ||
nextjs.handle(req, res); | ||
}); | ||
|
||
app.listen(port, function() { | ||
console.log(`started on port ${port}`); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as express from 'express'; | ||
import * as next from "next"; | ||
|
||
const isDev = process.env.NODE_ENV !== 'production'; | ||
|
||
const nextApp = next({ dev: isDev }); | ||
const handle = nextApp.getRequestHandler(); | ||
|
||
const nextjs = { | ||
nextApp, | ||
handle, | ||
render: (req: express.Request, res: express.Response, page: string) => nextApp.render(req, res, page), | ||
}; | ||
|
||
export default nextjs; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as express from 'express'; | ||
import * as graphqlHTTP from 'express-graphql'; | ||
import schema from '../graph'; | ||
|
||
const router = express.Router(); | ||
|
||
router.get('/graphql', graphqlHTTP({ | ||
schema, | ||
graphiql: true, | ||
})) | ||
|
||
router.post('/graphql', graphqlHTTP({ | ||
schema, | ||
graphiql: false, | ||
})) | ||
|
||
export default router; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as express from 'express'; | ||
import * as asyncRouter from 'express-router-async'; | ||
import nextjs from '../lib/next'; | ||
|
||
const router = asyncRouter(); | ||
|
||
router.get('/', (req: express.Request, res: express.Response) => { | ||
nextjs.render(req, res, '/'); | ||
}); | ||
|
||
router.getAsync('/home', async (req: express.Request, res: express.Response) => { | ||
nextjs.render(req, res, '/home'); | ||
}); | ||
|
||
export default router; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"allowSyntheticDefaultImports": true, | ||
"jsx": "preserve", | ||
"lib": [ | ||
"dom", | ||
"es2017" | ||
], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmit": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"preserveConstEnums": true, | ||
"removeComments": false, | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "es6" | ||
}, | ||
"include": [ | ||
"./types/**/*" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"defaultSeverity": "error", | ||
"extends": [ | ||
"tslint:recommended", | ||
"tslint-config-prettier" | ||
], | ||
"jsRules": {}, | ||
"rules": { | ||
"quotemark": [ | ||
true, | ||
"single" | ||
] | ||
}, | ||
"rulesDirectory": [] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
declare namespace Express { | ||
interface IRoute { | ||
getAsync: express.IRouterMatcher<this>; | ||
postAsync: express.IRouterMatcher<this>; | ||
} | ||
} | ||
|
||
declare module 'express-router-async' { | ||
import * as express from 'express'; | ||
|
||
const router = express.IRouter; | ||
|
||
export = router: express.IRouter; | ||
}; |