@synthql/handler-express
v0.109.4
Published
SynthQL-compatible route handler function for use in [Express.js](https://expressjs.com/en/starter/installing.html) server app.
Downloads
1,870
Readme
@synthql/handler-express
SynthQL-compatible route handler function for use in Express.js server app.
// src/queryEngine.ts
import { QueryEngine } from '@synthql/backend';
export const queryEngine = new QueryEngine({
url: 'postgresql://user:password@localhost:5432/dbname',
});
// src/index.ts
import express from 'express';
import { createExpressSynthqlHandler } from '@synthql/handler-express';
import { queryEngine } from './queryEngine';
const app = express();
const expressSynthqlRequestHandler = createExpressSynthqlHandler(queryEngine);
app.post('/synthql', async (req, res) => {
return await expressSynthqlRequestHandler(req, res);
});
app.listen(3000);