Skip to content

Commit

Permalink
Merge pull request #17 from Nosesisaid/cors
Browse files Browse the repository at this point in the history
Add cors
  • Loading branch information
v1ctorio committed Jun 24, 2022
2 parents 29fdb89 + 6f5643f commit 88a8235
Show file tree
Hide file tree
Showing 3 changed files with 530 additions and 544 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"author": "Nosesisaid",
"license": "MIT",
"dependencies": {
"@fastify/cors": "7.0.0",
"@fastify/mongodb": "5.0.0",
"dotenv": "16.0.1",
"fastify": "3.29.0"
Expand Down
6 changes: 6 additions & 0 deletions src/App.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import fastify, { FastifyServerOptions } from 'fastify';
import fastifyMongodb from '@fastify/mongodb';
import './config/env';
import cors from '@fastify/cors';

function build(opts:FastifyServerOptions={}) {
const App = fastify(opts);

App.register(fastifyMongodb, {
url: process.env.MONGO_URL
});
App.register(cors, {
origin: '*'
});

App.get('/', async (req, res) => {
const fumos = await App.mongo.db?.collection('fumos').find({}).toArray();
Expand Down
Loading

0 comments on commit 88a8235

Please sign in to comment.