Skip to content

Electronics-api är en RESTful API byggd med Node.js och SQLite-databas, som ger utvecklare enkel och effektiv hantering av elektroniska produkter, inklusive hämtning, läggning till och uppdatering av befintliga produkter. Det finns också stöd för autentisering med JWT-tokens.

Notifications You must be signed in to change notification settings

Ehnvik/electronics-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

electronics-api

This repository contains instructions for integrating a Strapi backend server with endpoints for electronics such as computers, mobiles, audio_devices and televisions.

Installation

To install the dependencies, run the following command in the createApi and the strapi-electronic directory of the project:

npm i

Create .env

To get access to the servers and JWT-SECRET you need to create a .env file in the createApi folder with the following structure:

Starting the Strapi Server

To start the Strapi server, navigate to the electronics-api/strapi-electronics directory and run the following command:

npm run develop

This will start the server at http://localhost:1337/api.

Starting the Backend Server

To start the backend server, run the following command in the createApi directory of the project:

npm start

This will start the server at http://localhost:8008.

Endpoints

The following endpoints are available for electronics:

  • /computers
  • /mobiles
  • /audio-devices
  • /televisions

To retrieve data from an endpoint, use a GET request to the appropriate URL, such as: GET http://localhost:8008/televisions

To create a new item, use a POST request to the appropriate URL, such as: POST http://localhost:8008/televisions

The request body should be in JSON format, with the following properties:

{ "data": { "name": "string", "description": "string", "manufacturer": "string", "price": number, "screen_size": number } }

To update an existing item, use a PUT request to the appropriate URL, such as: PUT http://localhost:8008/televisions/update/id

The request body should be in the same format as for creating a new item.

To delete an existing item, use a DELETE request to the appropriate URL, such as: DELETE http://localhost:8008/televisions/delete/id

Authentication

To perform POST, PUT, or DELETE requests, you must be logged in.

To register a new user, use a POST request to the following URL:

POST http://localhost:8008/users/register

The request body should be in JSON format, with the following properties:

{ "username": "string", "password": "string" }

To log in, use a POST request to the following URL: POST http://localhost:8008/users/login

The request body should be in the same format as for registering a new user. This will return a JSON Web Token (JWT), which should be included in the Authorization header of subsequent requests.

About

Electronics-api är en RESTful API byggd med Node.js och SQLite-databas, som ger utvecklare enkel och effektiv hantering av elektroniska produkter, inklusive hämtning, läggning till och uppdatering av befintliga produkter. Det finns också stöd för autentisering med JWT-tokens.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published