A simple URL redirect service using an in-memory JSON file. This project is built with TypeScript and Express.js.
redirector/
├── .gitignore
├── Dockerfile
├── package.json
├── tsconfig.json
└── src/
├── app.ts
├── redirects.json
└── redirect.ts
-
Clone the repository:
git clone https://github.com/itaibo/redirector.git cd redirector
-
Install dependencies:
npm install
The URL redirects are configured in the src/redirects.json
file. Here is an example:
{
"example": "https://www.example.com",
"example/nested": "https://nested.example.com"
}
To build the project, run:
npm run build
To start the project, run:
npm start
The service will be available at http://localhost:3000
, unless specified another one in the PORT
env variable.
To build and run the project using Docker:
-
Build the Docker image:
docker build -t redirector .
-
Run the Docker container:
docker run -p 3000:3000 redirector
The service will be available at http://localhost:3000
.
This project uses Prettier for code formatting. To format the code, run:
npm run format
- src/app.ts: Entry point of the application
- src/redirect.ts: Module responsible for loading and serving redirects
- src/redirects.json: JSON file containing URL redirects
This project is licensed under the MIT License. See the LICENSE file for details.