This project was developed as part of DIO's NodeJS Training, based on the original training repository: https://github.com/digitalinnovationone/formacao-nodejs
podcasts-manager-nodejs is a lightweight REST API for managing podcasts, written in TypeScript without any frameworks. The API provides functionalities for listing (all or filtered) podcasts while following a clean architecture approach.
- Built using pure TypeScript, without any frameworks.
- Modular architecture with Controller-Service-Repository layers.
- Supports development and production builds with TypeScript.
- Uses TSX for development and Tsup for bundling.
- Environment variable support using
.envfiles.
-
Clone the repository:
git clone https://github.com/fornari03/gerenciador-podcasts-nodejs.git cd gerenciador-podcasts-nodejs -
Install dependencies:
npm install
Run the server in development mode:
npm run start:devWatch mode (automatically reloads on file changes):
npm run start:watchBuild and start the production server:
npm run start:distTo test the project, you can use any HTTP client application such as Postman or Thunder Client. These applications allow you to make HTTP requests to your local server and interact with the API endpoints. Here's how you can test the project:
-
Make a GET Request
You can send a GET request to either of the following endpoints:http://localhost:PORT/api/listhttp://localhost:PORT/api/filter?p=PODCAST&c=CATEGORIES
Replace
PORTwith the port specified in your.envfile.
ThePODCASTandCATEGORIESparameters are optional and should be selected from the examples available in thepodcasts.jsonfile located in therepositoriesfolder of the project. You can choose to filter by either podcast or category, or both.For example:
http://localhost:PORT/api/filter?p=Podpah(filters only by podcast)http://localhost:PORT/api/filter?c=humor(filters only by category)http://localhost:PORT/api/filter?p=Flow+Podcast&c=saude(filter by both podcast and category)
-
Handling Missing or Empty Data
If no results match the query, the response will return aNO_CONTENTstatus.Example:
- Request:
http://localhost:PORT/api/filter?p=UnknownPodcast&c=UnknownCategory - Response:
NO_CONTENT
- Request:
The project follows a layered architecture to ensure separation of concerns:
/src
│ app.ts # Handles HTTP requests and routes them to the controllers
│ server.ts # Creates and starts the HTTP server
│
├── controllers # Handles HTTP requests and responses
│
├── models # TypeScript interfaces for data structures
│
├── repositories # Data access layer (database is actually a JSON file)
│
├── routes # Defines API routes
│
├── services # Business logic layer
│
├── utils # Helper enumerators and functions
- TypeScript - Static typing and improved development experience.
- TSX - Enhanced TypeScript execution for development.
- Tsup - Bundler for compiling TypeScript code.
- Node.js - JavaScript runtime environment.
If you encounter any issues or have suggestions for improvements, please open an issue here. Contributions are welcome!