text: const bodyParser = require("body-parser");
  const cors = require("cors");
  const express = require("express");
  const { ApolloServer, gql } = require("apollo-server-express");
  const expressJwt = require("express-jwt");
  const jwt = require("jsonwebtoken");
  const db = require("./db");
  
  const port = 9000;
  const jwtSecret = Buffer.from("Zn8Q5tyZ/G1MHltc4F/gTkVJMlrbKiZt", "base64");
  
  // Construct a schema, using GraphQL schema language
  const typeDefs = gql`
    type Query {
      hello: String
    }
  `;
  
  // Provide resolver functions for your schema fields
  const resolvers = {
    Query: {
      hello: () => "Hello world!",
    },
  };
  
  const server = new ApolloServer({ typeDefs, resolvers });
  
  const app = express();
  server.applyMiddleware({ app, path: "/graphql" });
  app.use(
    cors(),
    bodyParser.json(),
    expressJwt({
      secret: jwtSecret,
      credentialsRequired: false,
    })
  );
  
  app.post("/login", (req, res) => {
    const { email, password } = req.body;
    const user = db.users.list().find((user) => user.email === email);
    if (!(user && user.password === password)) {
      res.sendStatus(401);
      return;
    }
    const token = jwt.sign({ sub: user.id }, jwtSecret);
    res.send({ token });
  });
  
  app.listen(port, () => console.info(`Server started on port ${port}`));
  