Commit 9f54c925 authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira Committed by Stephanie Briere Americo
Browse files

Issue #68: Add CORS to back-end


Signed-off-by: Richard Fernando Heise Ferreira's avatarRichardHeise <rfhf19@inf.ufpr.br>
parent f7a5501b
......@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 1.2.1 - 05-03-2020
## Added
- Cors to integrate front-end with back-end #68 (Richard Heise)
### Changed
- Minor route order changes on main.ts to make it more intuitive
- Port on config.env from 3000 to 3333 for integration purpose
## 1.2.0 - 19-02-2020
### Changed
- Created a stable version with user
......
......@@ -28,6 +28,8 @@ Backend installation instructions:
The main objective of this project is create a *Web Service* which allows users
to create and update its own forms offering the following features.
If you want to update a VM follow the steps described on issue #67 (in portuguese): https://gitlab.c3sl.ufpr.br/simmctic/form-creator/form-creator-api/issues/67
* Versionable
* The form can be updated, and answers of several versions are stored.
* Validable
......
......@@ -6,7 +6,7 @@
# to undesired eyes.
# You should not modify this file. You should copy it and edit and use the copy.
PORT=3000
PORT=3333
# This should be a secret key to encode the informations on the token
JWT_KEY="secret_very_long_string_key"
{
"name": "form-creator-api",
"version": "1.2.0",
"version": "1.2.1",
"description": "RESTful API used to manage and answer forms.",
"main": "index.js",
"scripts": {
......@@ -19,9 +19,11 @@
"dependencies": {
"@types/async": "^2.0.50",
"@types/bcrypt": "^3.0.0",
"@types/cors": "^2.8.6",
"@types/express": "^4.16.0",
"@types/pg": "^7.4.13",
"async": "^2.6.1",
"cors": "^2.8.5",
"express": "^4.16.4",
"pg": "^7.8.1",
"ts-node": "^7.0.1",
......
......@@ -25,6 +25,7 @@
import * as bodyParser from "body-parser";
import * as express from "express";
const cors = require("cors");
// Create a new express app
/** @hidden */
......@@ -47,6 +48,7 @@ import { tokenValidation } from "./api/middlewares/userAuth";
// Setup middlewares
app.use("/", bodyParser.json());
app.use("/", DbHandlerMw());
app.use(cors());
// Setup routes
......@@ -54,13 +56,13 @@ app.get("/form/:id", FormCtrl.read);
app.put("/form/:id", tokenValidation(), FormCtrl.update);
app.post("/form", tokenValidation(), FormCtrl.write);
app.post("/answer/:id", AnswerCtrl.write);
app.get("/answer/:id", tokenValidation(), AnswerCtrl.read);
app.post("/user/signUp", UserCtrl.signUp);
app.post("/user/signIn", UserCtrl.signIn);
app.delete("/user/deleteData/:id", tokenValidation(), UserCtrl.deleteData);
app.put("/user/changePassword", tokenValidation(), UserCtrl.changePassword);
app.get("/user/list/:id", UserCtrl.listForms);
app.put("/user/update", tokenValidation(), UserCtrl.update);
app.get("/answer/:id", tokenValidation(), AnswerCtrl.read);
app.delete("/user/deleteData/:id", tokenValidation(), UserCtrl.deleteData);
// Listening
......
......@@ -37,6 +37,13 @@
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.1.tgz#90b68446364baf9efd8e8349bb36bd3852b75b80"
integrity sha512-aRnpPa7ysx3aNW60hTiCtLHlQaIFsXFCgQlpakNgDNVFzbtusSY8PwjAQgRWfSk0ekNoBjO51eQRB6upA9uuyw==
"@types/cors@^2.8.6":
version "2.8.6"
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.6.tgz#cfaab33c49c15b1ded32f235111ce9123009bd02"
integrity sha512-invOmosX0DqbpA+cE2yoHGUlF/blyf7nB0OGYBBiH27crcVm5NmFaZkLP4Ta1hGaesckCi5lVLlydNJCxkTOSg==
dependencies:
"@types/express" "*"
"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
......@@ -50,6 +57,15 @@
"@types/node" "*"
"@types/range-parser" "*"
"@types/express@*":
version "4.17.3"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.3.tgz#38e4458ce2067873b09a73908df488870c303bd9"
integrity sha512-I8cGRJj3pyOLs/HndoP+25vOqhqWkAZsWMEmq1qXy/b/M3ppufecUwaK2/TVDVxcV61/iSdhykUjQQ2DLSrTdg==
dependencies:
"@types/body-parser" "*"
"@types/express-serve-static-core" "*"
"@types/serve-static" "*"
"@types/express@^4.16.0":
version "4.16.1"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.16.1.tgz#d756bd1a85c34d87eaf44c888bad27ba8a4b7cf0"
......@@ -551,6 +567,14 @@ core-util-is@~1.0.0:
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=
cors@^2.8.5:
version "2.8.5"
resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29"
integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==
dependencies:
object-assign "^4"
vary "^1"
debug@2.6.9, debug@^2.6.8:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
......@@ -1380,7 +1404,7 @@ number-is-nan@^1.0.0:
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=
object-assign@^4.1.0:
object-assign@^4, object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=
......@@ -2002,7 +2026,7 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
vary@~1.1.2:
vary@^1, vary@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc"
integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment