diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5aa7bace3f984c15cdc8c84cb4a9bd601d0acf7d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Stage 1: Base Image +FROM node:18-alpine as base +WORKDIR /api +COPY package*.json ./ +RUN npm install +COPY . . +ENV DATA_DIRECTORY=/data + +# Stage 2: Final Image for running the server +FROM base as server +EXPOSE 3000 +CMD ["npm", "run", "start"] + +# Stage 3: Final Image for running the tests +FROM base as test +CMD ["npm", "run", "test"] \ No newline at end of file diff --git a/README.md b/README.md index 5f50be6dc6870d8a2732e239aa21b4799eaf5bca..750046c4931a6ee3f5f221ffcffd0ef3e7708db7 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,98 @@ -# Plugin Store +# Plugins Store The idea is to provide the user a quick way to discover and install plugins via the plugin store. +# Prerequisites + ++ npm ++ Node.js 18.16+ ++ Docker + +# Installation of Node.js 18.16 + +how to install Node.js 18.16 with nvm + +`$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash` + +`$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash` + +`$ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"\n[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm` + +`$ command -v nvm` + +how to install Node.js 18.16 with nvm + +`$ nvm install 18.16.0` + +# Scripts + +run the server + +`$ npm run start` + +lint + +`$ npm run lint` + +fix the linting + +`$ npm run fix` + +run tests and see code coverage + +`$ npm run test` + +# Send API requests + +### Get all plugins + +`$ curl -X GET http://localhost:3000/` + +### Get a plugin's details + +`$ curl -X GET http://localhost:3000/details/AudioFilter` + +### Download a plugin by its id + +`$ curl -X GET http://localhost:3000/download/AudioFilter.jpl` + # Contributing -We have a set of ESLint rules that define clear syntax rules (web/.eslintrc.json). You will need the following tools: +We have a set of ESLint rules that define clear syntax rules (/.eslintrc.json). You will need the following tools: -* ESLint (The pluggable linting utility for JavaScript and JSX) https://eslint.org/ +* ESLint (https://eslint.org/) We will not accept patches introducing non-ESLint-compliant code. -## Linting via pre-commit hook +# Docker + +To install Docker please read this manual: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository + +The Docker needs a data directory to store the plugins. You need a /data/ folder in your repo. The API will look for the plugins in this folder. This is a temporary situation until we have a database implemented. + +Build a docker image: + +`docker build -t server-image --target server .` + + +Run the docker container: + +`docker run -p 3000:3000 -ti server-image` + + +To stop the container do CTRL + C in the terminal. + +To run tests in the docker container + +Build the test image: + +`docker build -t test-image --target test .` + +Run the test image: + +`docker run test-image` + +# Linting via pre-commit hook Set up the pre-commit hook: diff --git a/api/package.json b/api/package.json index 4d31773e5aa67680cbf72ece22f6b203faa1ee24..5b15b9da09a84f96fe4cb696cf313e0ff3253045 100644 --- a/api/package.json +++ b/api/package.json @@ -7,7 +7,8 @@ "start": "ts-node index.ts", "build": "tsc", "lint": "eslint . --ext .ts", - "fix": "eslint . --ext .ts --fix" + "fix": "eslint . --ext .ts --fix", + "build": "tsc" }, "author": "", "license": "ISC", diff --git a/documentation.md b/documentation.md index 55d8f3dd5ced50e7c662b5874aa7451986ac8c73..a776380a4d9afddb10548d9425632e65665fe482 100644 --- a/documentation.md +++ b/documentation.md @@ -15,7 +15,7 @@ The endpoint to retrieve the list of plugins needs to support a per-page query p ### Code Example ```http -GET /plugins/ +GET ``` Successful response: