@dupkey/mariadb-lambda
v1.0.4
Published
Middy compatible MariaDB middleware and connection object.
Downloads
12
Readme
@dupkey/mariadb-lambda
Middy compatible MariaDB middleware and connection object.
Install
npm install @dupkey/mariadb-lambda
Server Example
import { mariadbMiddleware } from '@dupkey/mariadb-lambda';
import { ApolloServer } from 'apollo-server-lambda';
import * as middy from 'middy';
import schema from "./schema";
const server = new ApolloServer({
schema,
context: ({ event, context }) => ({
headers: event.headers,
functionName: context.functionName,
event,
context
})
});
const serverHandler = server.createHandler({
cors: {
origin: process.env.CORS,
credentials: true,
}
});
export const handler = middy(serverHandler).use(mariadbMiddleware(
String(process.env.MARIADB_HOST),
String(process.env.MARIADB_USER),
String(process.env.MARIADB_PASSWORD),
String(process.env.MARIADB_DATABASE),
{ namedPlaceholders: true }
));
To do
- Upgrade to next release of 'mariadb'
- yarn remove @types/geojson
- yarn remove geojson
Build the TypeScript and JavaScript versions
npm run build
Run the tests
npm test
VS Code Debugging
Create a launch.json
file in your .vscode folder with the following:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--require", "ts-node/register",
"-u", "tdd",
"--timeout", "999999",
"--colors", "--recursive",
"${workspaceFolder}/test/**/*.ts"
],
"internalConsoleOptions": "openOnSessionStart"
}
]
}
In the debug tab (Ctrl+Shift+D) select "Mocha Tests" from the dropdown and then click "Start Debugging". Results will display in the console on the bottom of the VS Code.