Update API dependencies and migrate to Apollo Server v3.
This commit is contained in:
parent
4b8ab99a11
commit
aed05449dc
1928
api/package-lock.json
generated
1928
api/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,24 +20,24 @@
|
|||||||
"npm": ">= 7"
|
"npm": ">= 7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"apollo-server-koa": "^2.25.1",
|
"apollo-server-koa": "^3.1.1",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
"graphql": "^15.5.0",
|
"graphql": "^15.5.1",
|
||||||
"graphql-upload": "^12.0.0",
|
"graphql-upload": "^12.0.0",
|
||||||
"koa": "^2.13.1",
|
"koa": "^2.13.1",
|
||||||
"make-dir": "^3.1.0",
|
"make-dir": "^3.1.0",
|
||||||
"shortid": "^2.2.16"
|
"shortid": "^2.2.16"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^7.28.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-env": "^21.0.0",
|
"eslint-config-env": "^22.0.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-plugin-import": "^2.23.4",
|
||||||
"eslint-plugin-jsdoc": "^35.3.0",
|
"eslint-plugin-jsdoc": "^36.0.6",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^3.4.0",
|
"eslint-plugin-prettier": "^3.4.0",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^2.0.12",
|
||||||
"prettier": "^2.3.1"
|
"prettier": "^2.3.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run test:eslint && npm run test:prettier",
|
"test": "npm run test:eslint && npm run test:prettier",
|
||||||
|
|||||||
@ -6,25 +6,6 @@ import makeDir from 'make-dir';
|
|||||||
import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs';
|
import UPLOAD_DIRECTORY_URL from './config/UPLOAD_DIRECTORY_URL.mjs';
|
||||||
import schema from './schema/index.mjs';
|
import schema from './schema/index.mjs';
|
||||||
|
|
||||||
const app = new Koa().use(
|
|
||||||
graphqlUploadKoa({
|
|
||||||
// Limits here should be stricter than config for surrounding
|
|
||||||
// infrastructure such as Nginx so errors can be handled elegantly by
|
|
||||||
// `graphql-upload`:
|
|
||||||
// https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
|
|
||||||
maxFileSize: 10000000, // 10 MB
|
|
||||||
maxFiles: 20,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
new ApolloServer({
|
|
||||||
// Disable the built in file upload implementation that uses an outdated
|
|
||||||
// `graphql-upload` version, see:
|
|
||||||
// https://github.com/apollographql/apollo-server/issues/3508#issuecomment-662371289
|
|
||||||
uploads: false,
|
|
||||||
schema,
|
|
||||||
}).applyMiddleware({ app });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the API server.
|
* Starts the API server.
|
||||||
*/
|
*/
|
||||||
@ -32,13 +13,29 @@ async function startServer() {
|
|||||||
// Ensure the upload directory exists.
|
// Ensure the upload directory exists.
|
||||||
await makeDir(fileURLToPath(UPLOAD_DIRECTORY_URL));
|
await makeDir(fileURLToPath(UPLOAD_DIRECTORY_URL));
|
||||||
|
|
||||||
app.listen(process.env.PORT, (error) => {
|
const apolloServer = new ApolloServer({ schema });
|
||||||
if (error) throw error;
|
|
||||||
|
|
||||||
console.info(
|
await apolloServer.start();
|
||||||
`Serving http://localhost:${process.env.PORT} for ${process.env.NODE_ENV}.`
|
|
||||||
);
|
new Koa()
|
||||||
});
|
.use(
|
||||||
|
graphqlUploadKoa({
|
||||||
|
// Limits here should be stricter than config for surrounding
|
||||||
|
// infrastructure such as Nginx so errors can be handled elegantly by
|
||||||
|
// `graphql-upload`:
|
||||||
|
// https://github.com/jaydenseric/graphql-upload#type-processrequestoptions
|
||||||
|
maxFileSize: 10000000, // 10 MB
|
||||||
|
maxFiles: 20,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.use(apolloServer.getMiddleware())
|
||||||
|
.listen(process.env.PORT, (error) => {
|
||||||
|
if (error) throw error;
|
||||||
|
|
||||||
|
console.info(
|
||||||
|
`Serving http://localhost:${process.env.PORT} for ${process.env.NODE_ENV}.`
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
startServer();
|
startServer();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user