Skip to content

how start a project using express and node js? #5026

Discussion options

You must be logged in to vote

your can make this in your initial file from project, this example contain a route and config to use node and express

import express, { json, NextFunction, Request, Response, Router } from "express";
import "module-alias/register";
import "reflect-metadata";

export const cors = (req: Request, res: Response, next: NextFunction): void => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header(
    "Access-Control-Allow-Headers",
    "Origin, X-Requested-With, Content-Type, Accept, Authorization"
  );
  res.header("Access-Control-Allow-Methods", "*");
  next();
};

export const contentType = (
  req: Request,
  res: Response,
  next: NextFunction
): void => {
  res.type("json");
  …

Replies: 0 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by EduardoNoronha31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants