1.0.0 • Published 3 years ago

@techmason/express-graphql-rest v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

creating server project

The main idea of this project is to create a single source for all of backend api. This will be inside the node modules of the project and act as the server with all basic configurations build with this.

Use graphql

import { graphqlServer, resolvers, typeDefs } from "@techmason/express-graphql-rest";

graphqlServer.createApolloServer(
  typeDefs,
  resolvers,
  () => {
    //   All req will pass through context
    return { contextData: 'From context' };
  },
  { port: 5000 },
);

Use rest

import { ExpressHttpServerMethods, ExpressRoutes, expressServer } from "@techmason/express-graphql-rest";

class TestClass implements ExpressRoutes {
    routesDefinition(httpServer: ExpressHttpServerMethods): void {
        httpServer.get("/", (_, res) => {
            res.status(200).json({
                message: "s Test Data of get",
            });
        });
    }
}
expressServer.startServer({port: 4000}, [new TestClass])