Convert the API from CJS to ESM.
This commit is contained in:
parent
ee4b815fbb
commit
3fff0d9230
@ -45,6 +45,6 @@
|
||||
"test:eslint": "eslint .",
|
||||
"test:prettier": "prettier -c .",
|
||||
"dev": "nodemon -i db.json",
|
||||
"start": "node -r dotenv/config server"
|
||||
"start": "node -r dotenv/config server.mjs"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
import {
|
||||
GraphQLID,
|
||||
GraphQLNonNull,
|
||||
GraphQLObjectType,
|
||||
GraphQLString,
|
||||
GraphQLID,
|
||||
} = require('graphql');
|
||||
} from 'graphql';
|
||||
|
||||
module.exports = new GraphQLObjectType({
|
||||
export default new GraphQLObjectType({
|
||||
name: 'File',
|
||||
description: 'A stored file.',
|
||||
fields: () => ({
|
||||
@ -1,10 +1,8 @@
|
||||
'use strict';
|
||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
||||
import { GraphQLUpload } from 'graphql-upload';
|
||||
import FileType from './FileType.mjs';
|
||||
|
||||
const { GraphQLList, GraphQLObjectType, GraphQLNonNull } = require('graphql');
|
||||
const { GraphQLUpload } = require('graphql-upload');
|
||||
const FileType = require('./FileType');
|
||||
|
||||
module.exports = new GraphQLObjectType({
|
||||
export default new GraphQLObjectType({
|
||||
name: 'Mutation',
|
||||
fields: () => ({
|
||||
singleUpload: {
|
||||
@ -1,9 +1,7 @@
|
||||
'use strict';
|
||||
import { GraphQLList, GraphQLNonNull, GraphQLObjectType } from 'graphql';
|
||||
import FileType from './FileType.mjs';
|
||||
|
||||
const { GraphQLList, GraphQLObjectType, GraphQLNonNull } = require('graphql');
|
||||
const FileType = require('./FileType');
|
||||
|
||||
module.exports = new GraphQLObjectType({
|
||||
export default new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
fields: () => ({
|
||||
uploads: {
|
||||
@ -1,10 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { GraphQLSchema } = require('graphql');
|
||||
const MutationType = require('./MutationType');
|
||||
const QueryType = require('./QueryType');
|
||||
|
||||
module.exports = new GraphQLSchema({
|
||||
query: QueryType,
|
||||
mutation: MutationType,
|
||||
});
|
||||
8
api/schema/index.mjs
Normal file
8
api/schema/index.mjs
Normal file
@ -0,0 +1,8 @@
|
||||
import { GraphQLSchema } from 'graphql';
|
||||
import MutationType from './MutationType.mjs';
|
||||
import QueryType from './QueryType.mjs';
|
||||
|
||||
export default new GraphQLSchema({
|
||||
query: QueryType,
|
||||
mutation: MutationType,
|
||||
});
|
||||
@ -1,14 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const { createWriteStream, unlink } = require('fs');
|
||||
const { ApolloServer } = require('apollo-server-koa');
|
||||
const { graphqlUploadKoa } = require('graphql-upload');
|
||||
const Koa = require('koa');
|
||||
const lowdb = require('lowdb');
|
||||
const FileSync = require('lowdb/adapters/FileSync');
|
||||
const mkdirp = require('mkdirp');
|
||||
const shortid = require('shortid');
|
||||
const schema = require('./schema');
|
||||
import { createWriteStream, unlink } from 'fs';
|
||||
import { ApolloServer } from 'apollo-server-koa';
|
||||
import { graphqlUploadKoa } from 'graphql-upload';
|
||||
import Koa from 'koa';
|
||||
import lowdb from 'lowdb';
|
||||
import FileSync from 'lowdb/adapters/FileSync.js';
|
||||
import mkdirp from 'mkdirp';
|
||||
import shortid from 'shortid';
|
||||
import schema from './schema/index.mjs';
|
||||
|
||||
const UPLOAD_DIR = './uploads';
|
||||
const db = lowdb(new FileSync('db.json'));
|
||||
Loading…
x
Reference in New Issue
Block a user