Giter Site home page Giter Site logo

sandwich-api's Introduction

sandwich-api

An API for sandwiches. ๐Ÿž๐Ÿ…๐Ÿ—๐Ÿฅ‘๐Ÿ–

API Documentation

  • GET /sandwich/{string}

Gets a sandwich with name string.

  • POST /sandwich

Submits a new sandwich to the database. Sandwich data should be in the POST body, of the form:

{ 
	"name": {string}, 
	"chicken-count": {int}, 
	"ham-count": {int}, 
	"lettuce-count": {int}, 
	"mozzarella-count": {int}, 
	"bacon-count": {int}, 
	"avocado-count": {int} 
}

Returned body is {"result": "success"} if the sandwich was successfully persisted, {"result": "failure"} if it was not. Failure is guaranteed if a sandwich with that name has already been POSTed.

Why?

I wanted to practice and demonstrate my Clojure capabilities. This is a mini-API about sandwiches with certain quantities of chicken, ham, lettuce, mozzarella, bacon, and avocado, but its main purpose is to show that I can use Ring, Compojure, JDBC, and PostgreSQL in Clojure.

Caveats

This is code mainly for reading, not running. It does run, but you would need to set up a PostgreSQL database at localhost:5432 with user postgres and password admin, unless you wanted to modify the hardcoded permissions.

Maybe I'll get around to parsing a config file or some flags on startup one day. We'll see!

BIG CAVEAT: nothing has been done to sanitize the strings submitted to the GET /sandwich/{string} route, so this would obviously not be secure!

sandwich-api's People

Contributors

sebastiankg avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.