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

add backend API routes #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Hono } from 'hono';
import { cors } from 'hono/cors';
import v1App from './router/v1/v1.router';
import v1App from './router/v1.router';

const app = new Hono();

Expand Down
21 changes: 21 additions & 0 deletions server/src/router/v1.router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Hono } from 'hono';

import users from './v1/users';
import events from './v1/events';
import company from './v1/company';
import equipment from './v1/equipment';
import project from './v1/projects';
import majors from './v1/majors';
import officers from './v1/officers';

const v1App = new Hono();

v1App.route('/users', users);
v1App.route('/events', events);
v1App.route('/company', company);
v1App.route('/equipment', equipment);
v1App.route('/project', project);
v1App.route('/majors', majors);
v1App.route('/officers', officers);

export default v1App;
20 changes: 20 additions & 0 deletions server/src/router/v1/company.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Hono } from 'hono';

const company = new Hono();

company.get('/:companyID/events', c => {
const companyID = c.req.param('companyID');
return c.json({ companyID });
});

company.get('/:companyID/subsribers', c => {
const companyID = c.req.param('companyID');
return c.json({ companyID });
});

company.get('/:companyID/subscribers/count', c => {
const companyID = c.req.param('companyID');
return c.json({ companyID });
});

export default company;
17 changes: 17 additions & 0 deletions server/src/router/v1/equipment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Hono } from 'hono';

const equipment = new Hono();

equipment.get('/', c => c.json({}));

equipment.get('/:equipmentTypeID/equipment-items', c => {
const equipmentTypeID = c.req.param('equipmentTypeID');
return c.json({ equipmentTypeID });
});

equipment.get('/equipmentitem/:equipmentItemID/rental-history', c => {
const equipmentItemID = c.req.param('equipmentItemID');
return c.json({ equipmentItemID });
});

export default equipment;
27 changes: 27 additions & 0 deletions server/src/router/v1/events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Hono } from 'hono';

const events = new Hono();

events.get('/', c => c.json({}));

events.get('/:eventID/companies', c => {
const eventID = c.req.param('eventID');
return c.json({ eventID });
});

events.get('/:eventID/subscribers', c => {
const eventID = c.req.param('eventID');
return c.json({ eventID });
});

events.get('/:eventID/subscribers/count', c => {
const eventID = c.req.param('eventID');
return c.json({ eventID });
});

events.get('/:eventID/files', c => {
const eventID = c.req.param('eventID');
return c.json({ eventID });
});

export default events;
12 changes: 12 additions & 0 deletions server/src/router/v1/majors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Hono } from 'hono';

const majors = new Hono();

majors.get('/', c => c.json({}));

majors.get('/:majorName/users', c => {
const majorName = c.req.param('majorName');
return c.json({ majorName });
});

export default majors;
7 changes: 7 additions & 0 deletions server/src/router/v1/officers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Hono } from 'hono';

const officers = new Hono();

officers.get('/', c => c.json({}));

export default officers;
25 changes: 25 additions & 0 deletions server/src/router/v1/projects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Hono } from 'hono';
import { db } from '../../db/db';
import { projects as projectsSchema } from '../../db/schema';
import type { Project } from '../../db/schema';

const projects = new Hono();

projects.get('/', async c => {
const foundProjects: Project[] = await db.select().from(projectsSchema);
return c.json({
projects: foundProjects,
});
});

projects.get('/:projectID/interested', c => {
const projectID = c.req.param('projectID');
return c.json({ projectID });
});

projects.get('/:projectID/files', c => {
const projectID = c.req.param('projectID');
return c.json({ projectID });
});

export default projects;
17 changes: 17 additions & 0 deletions server/src/router/v1/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Hono } from 'hono';
import { db } from '../../db/db';
import { users } from '../../db/schema';
import type { User } from '../../db/schema';

const usersRouter = new Hono();

usersRouter.get('/', async c => {
const foundUsers: User[] = await db.select().from(users);
return c.json({
users: foundUsers,
});
});

usersRouter.get('/rental-history', c => c.json({}));

export default usersRouter;
24 changes: 0 additions & 24 deletions server/src/router/v1/v1.router.ts

This file was deleted.