Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BK]: Index routes #17

Open
Villarley opened this issue Dec 13, 2024 · 40 comments
Open

[BK]: Index routes #17

Villarley opened this issue Dec 13, 2024 · 40 comments
Assignees

Comments

@Villarley
Copy link
Contributor


File: /src/routes/index.ts

import { Router } from 'express';
import userRoutes from './user.routes';
import productRoutes from './product.routes';
import storeRoutes from './store.routes';

const router = Router();

// Health Check Route
router.get('/health', (req, res) => {
    res.status(200).json({ status: 'success', message: 'API is running!' });
});

// Mount route modules
router.use('/users', userRoutes);
router.use('/products', productRoutes);
router.use('/stores', storeRoutes);

export default router;

Explanation

  1. Health Check Route:

    • Endpoint: /health
    • Description: Verifies if the API is up and running by returning a success message.
  2. Mounting Routes:

    • /users: Delegated to userRoutes.
    • /products: Delegated to productRoutes.
    • /stores: Delegated to storeRoutes.

Each of these modules (user.routes.ts, product.routes.ts, and store.routes.ts) should handle the specific logic and sub-routes for their respective entities.


Usage in Server File

In the main server file (e.g., server.ts), import and use the index routes:

import express from 'express';
import indexRoutes from './routes/index';

const app = express();
const PORT = process.env.PORT || 3000;

// Middleware for JSON parsing
app.use(express.json());

// Use the index routes
app.use('/api/v1', indexRoutes);

app.listen(PORT, () => {
    console.log(\`Server is running on http://localhost:\${PORT}\`);
});

Benefits

  • Centralized Routing: All module routes are defined and mounted in a single location.
  • Scalability: New modules can be easily added by creating their respective routes file and mounting them in index.ts.
  • Health Check: Provides a simple endpoint to monitor the API status.

By following this structure, the project remains organized and adheres to best practices for scalable backend applications.

@mimisavage
Copy link

May I try my hand at this?

@DanielVillatoro
Copy link
Contributor

Hi, could you assign this to me? I have strong experience in Typescript and can set up and organize the routes as outlined

@sonkeydotcom
Copy link

Hi. Id love to give this a try. ETA 1day. I’m a full stack engineer and also new member of the dojo community

@anonfedora
Copy link

  1. Will design an index router (index.ts) that serves as the main entry point for all routes. This router will import and mount specific route modules, providing a centralized routing configuration.
  2. Will create separate route files for different entities (users, products, stores) that define specific routes and handlers for each domain.
  3. Implement a Health Check: will add a simple health check route in the central router to provide a quick way to verify the API's operational status
  4. In the main server file, will import the central router and use it with a base path (e.g., '/api/v1').
  5. Esure Scalability: Will design the routing structure to be easily extensible. When adding new features, you can simply create a new route module and mount it in the index router without disrupting existing routes.
    ETA: 48 hours

@ShantelPeters
Copy link

I'd be happy to do this.

@fabrobles92
Copy link

Hello Fab here,

I am a full stack engineer member of Dojo Coding with experience in Express,js, Next Js, Vue and plain react, also I have plenty of contribution to web3 projects where that experience can help me deliver a quality solution

How I plan to tackle the issue:

Mount and index existing routes to the correct endpoint
Test the routes with postman
Modify test (if necessary)

@tosinmoses384
Copy link

I'd love to give this a go.

@GideonBature
Copy link

I'd be happy to do this.

My name is Gideon Bature a Software Engineer, I have experience building web applications with JavaScript/TypeScript on the Backend. If assigned, will send my first PR in 72 hours from that time.

Thank you!

@od-hunter
Copy link

Hi, please can I be assigned this please? I would love to be the given the opportunity to solve this issue please. I have experience in html, css, JavaScript, TypeScript, cairo and rust.

Summary of the steps I'll take:

  1. I'll use express.Router() to centralize route management in src/routes/index.ts.
    Mount userRoutes, productRoutes, and storeRoutes under /users, /products, and /stores, respectively.
  2. I'll then implement GET /health to return a JSON status response for API monitoring.
  3. I'll now use express.json() in the main server file (server.ts) to parse incoming JSON payloads and mount indexRoutes at /api/v1 to prefix all API endpoints.
  4. I'll start the express server on a specified PORT and log the running URL and for my modules I'll create a *.routes.ts file and import and mount it in index.ts.
    Lastly, I'll test

ETA: 1 day to raise a good pr
KINdly assign me please.

@pheobeayo
Copy link

I’d like to work on this.

@Benjtalkshow
Copy link

May I try my hand at this?

@Nityam573
Copy link

May I be assigned to this?

@psychemist
Copy link

Hello, StarShop project maintainers!
I am a fullstack web developer and a recent alumni of Web3Bridge, the largest and most sought after blockchain developer community in Africa. I have extensive experience building backend systems, implementing user authentication, and serving web resources over a fully fleshed-out and documented API. I am a new contributor to OnlyDust and would love to take on this task to increase my knowledge base and contribute to your open source project.

Over my years of experience, I have worked with languages and tools like:

Web3: Solidity and Rust
Backend: Express.js, Nest.js, Django, FastAPI, and Flask
Frontend: HTML/CSS, JavaScript/TypeScript, Tailwind, Shadcn/UI, React.js, and Next.js

Here is how I would solve this issue:

  • Implement a centralized routing system to streamline all API endpoints.
  • Define a reusable health check route to verify the API's operational status and provide instant feedback during downtime.
  • Organize route modules (users, products, stores) into separate, dedicated files to keep the codebase modular and easy to navigate.
  • Mount each module’s routes using intuitive paths (/users, /products, /stores) for clarity.
  • Integrate the centralized routing structure into the main server file using a versioned API base path (/api/v1)

I aim to complete this task within 36 hours being assigned and setting up my development environment, with my first pull request submitted before 12 hours have elapsed. I have an incredible work ethic and can deliver on this task.

Thank you for the opportunity and I look forward to working with you. LET'S BUILD! 🚀

@kayceeDev
Copy link

Hi, My Github name is: @kayceeDev,
I am a skilled backed engineer experience in Nodjs and Express using typescript.
I can tackle this challenge by origanizing the relevant routes to their routes to the specific controllers.

With my solid understanding of git and github and various contributions to open source projects, I will create thess routes in an efficient and scalable way.

Please assign this to me

@emarc99
Copy link

emarc99 commented Dec 13, 2024

The issue's guide is clearly defined, and I will do testing and build when I complete the task. ETA - 1day.

@caxtonacollins
Copy link

I will love to make contribution to this issue. Assign me, i will deliver a good PR in 24 hours

@Supa-mega
Copy link

I'd like to take this issue.first time contributor

@aurlic
Copy link

aurlic commented Dec 13, 2024

Hey I would love to get the chance to be assigned to this issue ! Thanks in advance

@Jagadeeshftw
Copy link

I'd love to give this a go.

@olisaagbafor
Copy link

Can I handle this issue?

@khayss
Copy link

khayss commented Dec 13, 2024

Hello, I'm a full-stack developer with experience building NodeJS backend using frameworks like ExpressJS and NestJS. I have a good understanding of what is required to complete this issue.

For this task, I'll implement the health check route and fix the necessary index routes.

@Superfly101
Copy link

Hello, I'm Daniel a software engineer passionate about problem solving and building products to meet users' needs. Mind if I try this one?

You have provided almost everything needed for this task, what would be left for me to do would be to create the routes/ directory inside the src/ directory then add the index.ts file and make necessary changes if needed.

Next would be to create the user.routes.ts, product.routes.ts, and store.routes.ts files and add the specific logic and sub-routes for their respective entities.

Lastly, make use of the index routes.

ETA: 2 business working day

@Ahmad940
Copy link

Let me jump on this, experienced backend and typescript developer here.

I can help create the controllers/routes folder and abstract the express routes with a custom typescript decorators eg @get(), @post, @put, @delete and automatically mount all routes that got the decorators for more readable and well maintain codebase following good design pattern.

@Dorcas18
Copy link

Can I try solving this issue?

@Joewizy
Copy link

Joewizy commented Dec 13, 2024

Is this issue still available?

@tosoham
Copy link

tosoham commented Dec 13, 2024

May I take care of this?

@BigBen-7
Copy link

let me get my hands on this please

@Amarjeet325
Copy link

I’d like to work on this.

@Michaelkingsdev
Copy link

Could I take on this issue?

@1nonlypiece
Copy link

Can I take care of this issue?

@ryzen-xp
Copy link

Mind if I take this issue?

@Thibrac
Copy link

Thibrac commented Dec 14, 2024

I've just finished the core curriculum at École 42, so solving this issue would be a step up in my learning curve!

@martinvibes
Copy link

i'm a frontend dev and blockchain dev
May I try my hand at this?
i would love to work on this and get it done

@vestor-dev
Copy link

May I handle this issue?
Would love to tackle this!
kindly assign :)

@Amarjeet325
Copy link

Hi , I am a full stack developer is a versatile professional skilled in both front-end and back-end development, capable of designing user interfaces, building robust server-side applications, and managing databases.
Can I take this from here? Thank you !

@BrunoAmbricca
Copy link

I would like to work on this issue

@3th-Enjay
Copy link

Can I take this from here?

@BraCR10
Copy link

BraCR10 commented Dec 15, 2024

Hello maintainers I'm BRACR10 from the Dojo Coding community, I would like to contribute to this project. I plan to mount and index existing routes to the correct endpoints and check if the API is running properly, as explained in the description. ETA 1~2 days.

@Villarley
Copy link
Contributor Author

hey @BraCR10
Task assigned to you. Let me know if you need further clarification or additional support!😊

Here is our telegram group, please join https://t.me/starshopcr

@Akanimorex
Copy link

I would love to take this on. Nodejs with typescript is my speciality and I believe i can fix this within 24 hours.

  • I'd solve this issue by implementing a centralized point for the APIs

  • Will create separate route files for different entities (users, products, stores) that define specific routes and handlers for each domain.

@BraCR10 BraCR10 mentioned this issue Dec 22, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests