Skip to content

ssinuco/clojure-burger-queen-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

burger-queen-api

A REST API which serves endpoints to create users, products and orders for a simple commerce. A swagger documentation is available here.

Endpoints

/users

  • GET /users
  • GET /users/:uid
  • POST /users
  • PUT /users/:uid
  • DELETE /users/:uid

/products

  • GET /products
  • GET /products/:productid
  • POST /products
  • PUT /products/:productid
  • DELETE /products/:productid

/orders

  • GET /orders
  • GET /orders/:orderId
  • POST /orders
  • PUT /orders/:orderId
  • DELETE /orders/:orderId

Implementation details

SQLite is used as database. next.jdbc is used for JDBC-based access to the database.

ring is used as web server.

compojure is used as routing library.

hugsql is used to define database functions from sql queries for creating a clean separation of Clojure and SQL code.

data.json is used for generating JSON response.

A next.jdbc.plan is used to reduce a join query.

A next.jdbc.with-transaction macro is used to warranty a correct order creation which requires insertion into two tables: orders and orders_products.

Projects files

  • connection.clj: connection and datasource for sqlite database
  • handler.clj: project entry point
  • middlewares.clj: web server middlewares
  • orders.clj: functions to handle orders endpoints
  • products.clj: function to handle products endpoints
  • routes.clj: API routes
  • users.clj: functions to handle users endpoints
  • utils.clj: some common functions
  • sql/orders.clj: function to reduce join query between orders and orders_products table.
  • sql/orders.sql: orders table queries
  • sql/products.sql: products table queries
  • sql/users.sql: users table queries

Prerequisites

You will need Leiningen 2.0.0 or above installed.

Running

To start a web server for the application, run:

lein ring server

License

Copyright © 2022 FIXME

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published