Prerequisites
- Node.js v14 or later with Express v4+ or AWS Lambda.
Clone the repository
Clone the JavaScript quickstarts GitHub repository.
git clone https://github.com/FireTail-io/javascript-quickstarts.git
Install
In your command line, type:
$ npm install --save firetail-js
Express.js Example
Setup
Place your API YAML file (swagger.yaml
) inside the root path of your application. Then run:
const express = require('express');
const firetailSetup = require("@public.firetail.io/firetail-api");
const app = express();
app.use(
express.raw({
inflate: true, limit: '50mb', type: () => true,
})
);
const firetailOpts = { dev: true, addApi: "./swagger.yaml" };
app.use(firetailSetup(firetailOpts));
app.get('/', (req, res) => {
res.send("FireTail sample");
});
const port = 3001;
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
Running the Application
In your command line, type:
AWS Lambda HelloWorld
Setup
- Place your API YAML file inside the root path of your application. Then run:
const firetailSetup = require("@public.firetail.io/firetail-api");
const firetailOpts = { addApi: "./swagger.yaml" };
const firetailWrapper = firetailSetup(firetailOpts);
module.exports.app = firetailWrapper((event, context) => {
return {
statusCode: 200,
body: "FireTail sample"
};
});
Example Open API Spec
openapi: 3.0.1
info:
title: example spec
version: '0.1'
paths:
/greet:
get:
operationId: app.greeting
responses:
200:
description: 200 response
content: {}