Skip to content

Commit

Permalink
added README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jonkirathe committed Sep 4, 2024
1 parent 01b742a commit b389520
Showing 1 changed file with 2 additions and 45 deletions.
47 changes: 2 additions & 45 deletions netlify/functions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ api.use('/api/', router);
export const handler = serverless(api);*/


/*import express, {Router} from "express";
import serverless from "serverless-http";
import jwt from 'jsonwebtoken';
import swaggerJsdoc from 'swagger-jsdoc';
import {swaggerOptions} from './swaggerConfig.js';
import morgan from 'morgan';
import cors from 'cors';
import swaggerUi from 'swagger-ui-express';
import express, {Router} from "express";
import {io} from "socket.io-client";

const api = express();
Expand Down Expand Up @@ -236,47 +236,4 @@ router.get("/hello", (req, res) =>

api.use("/api/", router);

export const handler = serverless(api);*/

import express, { Router } from "express";
import serverless from "serverless-http";
// import jwt from 'jsonwebtoken';
import swaggerJsdoc from 'swagger-jsdoc';
import { swaggerOptions } from './swaggerConfig.js';
import swaggerUi from "swagger-ui-express";

const api = express();

const router = Router();


const users = [
{ id: 1, email: 'user@example.com', password: 'password', role: 'user' },
];

/*const SECRET_KEY = 'vW8nF/bLKidnpIHC2ngYZNbdOe+tbFcoZ7muV0vCRYk=';
const REFRESH_SECRET_KEY = '3cN5xXHOsKhB7qxoDzWQcEMrtR0DZ6leTrkyHYOqIro=';
const generateTokens = (user) => {
const accessToken = jwt.sign({ id: user.id, email: user.email, role: user.role }, SECRET_KEY, { expiresIn: '15m' });
const refreshToken = jwt.sign({ id: user.id, email: user.email, role: user.role }, REFRESH_SECRET_KEY, { expiresIn: '7d' });
return { accessToken, refreshToken };
};*/

// Swagger setup
const specs = swaggerJsdoc(swaggerOptions);
api.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));

router.get('/check', (req, res) => {
res.status(200).json({ message: 'All working' });
});

router.get('/users', (req, res) => {
res.status(200).json({ users });
});

router.get("/hello", (req, res) => res.send("Hello World!"));

api.use("/api/", router);

export const handler = serverless(api);
export const handler = serverless(api);

0 comments on commit b389520

Please sign in to comment.