Skip to content

UCMercedACM/Tenaya

Repository files navigation

Onama

ACM UCM's Backend Calendar Management API

Onama is a pure backend API server written in Fiber a Golang module that mocks the style of Express.js

⚙️ Installation

First of all, download and install Go. 1.12 or higher is required.

Clone the repository to your local machine:

git clone https://github.com/UCMercedACM/Tenaya

Install all the necessary packages:

go install

🎯 Features

Middleware

/api --> assigns all headers for routes under API route

📜 Show code snippet
app.Use("/api", func(c *fiber.Ctx) {
    c.Set("Access-Control-Allow-Origin", "*")
    c.Set("Access-Control-Allow-Headers", "X-Requested-With")
    c.Set("Content-Type", "application/json")
    c.Next()
})

👀 Routing

GET

/api/events --> all calendar events

📜 Show code snippet
app.Get("/api/events", func(c *fiber.Ctx) { ... })

/api/events/:type --> return only a subgroup of all events

📜 Show code snippet
app.Get("/api/events/:type", func(c *fiber.Ctx) { ... })

/api/event/:id --> returns specific event

📜 Show code snippet
app.Get("/api/event/:id", func(c *fiber.Ctx) { ... })

POST

/api/events --> create multiple new events

📜 Show code snippet
app.Post("/api/events", func(c *fiber.Ctx) { ... })

/api/event --> create a single new event

📜 Show code snippet
app.Post("/api/event", func(c *fiber.Ctx) { ... })

PATCH

/api/events --> update the data of all events at once

📜 Show code snippet
app.Patch("/api/events", func(c *fiber.Ctx) { ... })

/api/events/:type --> update all the events of a single type

📜 Show code snippet
app.Patch("/api/events/:type", func(c *fiber.Ctx) { ... })

/api/event/:id --> update a single event

📜 Show code snippet
app.Patch("/api/event/:id", func(c *fiber.Ctx) { ... })

DELETE

/api/events --> completely delete all events

📜 Show code snippet
app.Delete("/api/events", func(c *fiber.Ctx) { ... })

/api/events/:type --> deletes all events under a specific type

📜 Show code snippet
app.Delete("/api/events/:type", func(c *fiber.Ctx) { ... })

/api/event/:id --> delete a specific event

📜 Show code snippet
app.Delete("/api/event/:id", func(c *fiber.Ctx) { ... })

Custom 404

* --> handles all unknown routes

📜 Show code snippet
app.Get("*", func(c *fiber.Ctx) {
    c.Status(404).Send("Unknown Request")
})

Releases

No releases published

Packages

No packages published