Skip to content

ademolaomosanya/Link-Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 

Repository files navigation

Link-Manager

HTTP Method API Endpoint Description Body
GET /links Get a list of all links.
GET /links Get a paginated list of all links.
GET /links/<link_id> Get a single link.
POST /links Create a new link url (required), tags (required), description (optional), name (required)
PUT /links/<link_id> Update a link url (required), tags (required), description (optional), name (required)
DELETE /links/<link_id> Delete a link

Additional Considerations

  • Validation and Error Handling: Implement validation for input parameters and clear error messages.
  • Search and Filtering: Add support for searching and filtering in the GET /links endpoint.
  • Versioning: Consider versioning for future changes.

How to Setup Nodejs-Typescript

Install typescript

  • Run the command to install the typescript package
npm install typescript --save-dev
  • Run the command to initialize tsconfig.json - this file will contain your typescript settings more like typescript rules you want to allow/disallow for your project.
tsc --init
  • Update the tsconfig.json file: specify the folder it will go to find the .ts file and tell it to exclude node_modules folder
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
  • Update the tsconfig.json file: Also specify the outDir value. Make sure to add build folder to gitignore
{
  ...
  "outDir": "build",/* Specify an output folder for all emitted files. */
  ...
}
  • Install ts-node - allow node to use typescript
npm install -D ts-node
npm install -D tslib @types/node

Update Scripts

  • First install nodemon
npm install -D nodemon
  • Update the script
  "scripts": {
    ...
    "start": "npm run build && node build/index.js",
    "dev": "nodemon --exec ts-node src/index.ts",
    "build": "tsc"
    ...
  },

Dependencies

Dev Dependencies

  1. typescript - to make our javascript typed

  2. ts-node - to run node with typescript

  3. nodemon - for hot reloading

Core Dependencies

  1. express
  2. mysql2 - MySQL client for Node.js
  3. body-parser - Node.js body parsing middleware.
  4. dotenv - loads environment variables from a .env file into process.env
  5. cors - to enable CORS

Releases

No releases published

Packages

No packages published