New linting for the API.
This commit is contained in:
parent
0e7723a00e
commit
409d1919c9
783
api/package-lock.json
generated
783
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -23,11 +23,15 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^7.2.3",
|
||||
"standard": "^10.0.2",
|
||||
"eslint": "^4.1.1",
|
||||
"eslint-plugin-import": "^2.7.0",
|
||||
"eslint-plugin-node": "^5.1.0",
|
||||
"eslint-plugin-prettier": "^2.1.2",
|
||||
"prettier": "^1.5.2",
|
||||
"webpack-watch-server": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"lint": "eslint .",
|
||||
"dev": "zoo webpack-watch-server",
|
||||
"build": "zoo webpack",
|
||||
"start": "zoo node dist"
|
||||
@ -49,10 +53,39 @@
|
||||
"stage-0"
|
||||
]
|
||||
},
|
||||
"standard": {
|
||||
"eslintConfig": {
|
||||
"parser": "babel-eslint",
|
||||
"ignore": [
|
||||
"dist/**"
|
||||
]
|
||||
}
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2017,
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:import/recommended",
|
||||
"plugin:node/recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"import",
|
||||
"node",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"node/no-unsupported-features": "off",
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"eslintIgnore": ["dist"]
|
||||
}
|
||||
|
||||
@ -5,12 +5,15 @@ const db = low('db.json', {
|
||||
storage
|
||||
})
|
||||
|
||||
db.defaults({
|
||||
uploads: []
|
||||
}).write()
|
||||
db
|
||||
.defaults({
|
||||
uploads: []
|
||||
})
|
||||
.write()
|
||||
|
||||
const saveFile = file => {
|
||||
return db.get('uploads')
|
||||
return db
|
||||
.get('uploads')
|
||||
.push({
|
||||
id: file.path,
|
||||
...file
|
||||
@ -22,14 +25,16 @@ const saveFile = file => {
|
||||
|
||||
export default {
|
||||
Query: {
|
||||
uploads () {
|
||||
uploads() {
|
||||
return db.get('uploads').value()
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
singleUpload: (_, {file}) => saveFile(file),
|
||||
multipleUpload (_, {files}) {
|
||||
return Promise.all(files.map(file => saveFile(file))).then(results => results)
|
||||
singleUpload: (_, { file }) => saveFile(file),
|
||||
multipleUpload(_, { files }) {
|
||||
return Promise.all(files.map(file => saveFile(file))).then(
|
||||
results => results
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,41 +4,37 @@ import cors from 'kcors'
|
||||
import compress from 'koa-compress'
|
||||
import KoaRouter from 'koa-router'
|
||||
import koaBody from 'koa-bodyparser'
|
||||
import {makeExecutableSchema} from 'graphql-tools'
|
||||
import {graphqlKoa} from 'graphql-server-koa'
|
||||
import {apolloUploadKoa} from 'apollo-upload-server'
|
||||
import { makeExecutableSchema } from 'graphql-tools'
|
||||
import { graphqlKoa } from 'graphql-server-koa'
|
||||
import { apolloUploadKoa } from 'apollo-upload-server'
|
||||
import typeDefs from './schema.graphql'
|
||||
import resolvers from './resolvers'
|
||||
|
||||
const app = new Koa()
|
||||
const router = new KoaRouter()
|
||||
const schema = makeExecutableSchema({
|
||||
typeDefs,
|
||||
resolvers
|
||||
})
|
||||
const schema = makeExecutableSchema({ typeDefs, resolvers })
|
||||
|
||||
// Enable Cross-Origin Resource Sharing (CORS)
|
||||
app.use(cors())
|
||||
|
||||
// Enable gzip
|
||||
app.use(compress())
|
||||
|
||||
// Parse body
|
||||
app.use(koaBody())
|
||||
app
|
||||
// Enable Cross-Origin Resource Sharing (CORS)
|
||||
.use(cors())
|
||||
// Enable gzip
|
||||
.use(compress())
|
||||
// Parse body
|
||||
.use(koaBody())
|
||||
|
||||
// GraphQL API
|
||||
router.post(
|
||||
'/graphql',
|
||||
apolloUploadKoa({
|
||||
uploadDir: '/tmp/apollo-upload-examples'
|
||||
}),
|
||||
graphqlKoa({
|
||||
schema
|
||||
})
|
||||
apolloUploadKoa({ uploadDir: '/tmp/apollo-upload-examples' }),
|
||||
graphqlKoa({ schema })
|
||||
)
|
||||
|
||||
app.use(router.routes())
|
||||
app.use(router.allowedMethods())
|
||||
app.use(router.routes()).use(router.allowedMethods())
|
||||
|
||||
app.listen(process.env.PORT)
|
||||
console.log(`Serving at http://localhost:${process.env.PORT} in ${process.env.NODE_ENV} mode.`)
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(
|
||||
`Serving at http://localhost:${process.env.PORT} in ${process.env
|
||||
.NODE_ENV} mode.`
|
||||
)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import path from 'path'
|
||||
import {NoEmitOnErrorsPlugin} from 'webpack'
|
||||
import { NoEmitOnErrorsPlugin } from 'webpack'
|
||||
|
||||
const config = {
|
||||
devtool: 'source-map',
|
||||
@ -17,27 +17,28 @@ const config = {
|
||||
__dirname: true
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
cacheDirectory: process.env.NODE_ENV === 'development'
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
cacheDirectory: process.env.NODE_ENV === 'development'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.(graphql|gql)$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'graphql-tag/loader'
|
||||
}
|
||||
}, {
|
||||
test: /\.(graphql|gql)$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'graphql-tag/loader'
|
||||
}]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
config.plugins = [
|
||||
new NoEmitOnErrorsPlugin()
|
||||
]
|
||||
config.plugins = [new NoEmitOnErrorsPlugin()]
|
||||
}
|
||||
|
||||
export default config
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user