GithubHelp home page GithubHelp logo

mguardarini / boilerplate-clojure-service Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 328 KB

Hey devs! Ready to dive into web API development with Clojure? Our handy boilerplate has everything you need to get started: easy routing, modular architecture, and useful middleware. Whether you're a pro or a beginning, this toolkit is here to help. Give it a try and let's build some awesome APIs together! ๐Ÿš€

Home Page: https://mguardarini.com/

License: Other

Clojure 100.00%

boilerplate-clojure-service's Introduction

Web API Boilerplate ๐Ÿš€

Visit my site: https://mguardarini.com/articles/boilerplate-clojure-service

This is a boilerplate for building a web API using Clojure. It provides a foundation for creating RESTful APIs with clean architecture and efficient handling of HTTP requests.

Dependencies ๐Ÿ’…

  • org.clojure/clojure "1.10.3": The core Clojure library.
  • compojure "1.6.1": A concise routing library for Ring/Clojure.
  • http-kit "2.3.0": An efficient, low-latency HTTP server/client library for Clojure.
  • com.stuartsierra/dependency "1.0.0" and com.stuartsierra/component "1.1.0": Libraries for managing dependencies and building component-based systems, respectively.
  • ring/ring-defaults "0.3.2": Ring middleware defaults for common settings.
  • prismatic/schema "1.4.1": A library for defining data schemas and validating data.
  • clj-http "3.12.3": A simple HTTP client for Clojure.

Features ๐Ÿ’…

  • Routing with Compojure: Define routes using Compojure's concise syntax.
  • Component-Based Architecture: Organize your application into modular components for better maintainability and testability.
  • Schema Validation: Use Prismatic Schema to define data schemas and validate incoming requests and outgoing responses.
  • HTTP Server: Run your API using the efficient HTTP server provided by http-kit.
  • Middleware: Leverage Ring middleware for handling common tasks such as JSON parsing, exception handling, and CORS.
  • HTTP Client: Interact with external APIs using the clj-http library.

Getting Started ๐Ÿฅ‡

  1. Clone this repository to your local machine:

    git clone [email protected]:mguardarini/boilerplate-clojure-service.git
    
  2. Run the tests

    lein test
    
  3. Install Leiningen if you haven't already:

    # For macOS/Linux
    brew install leiningen
    
    # For Windows
    scoop install leiningen
    
  4. Navigate to the project directory:

    cd boilerplate-clojure-service
    
  5. Start the development server:

    lein run
    
  6. Access your API at http://localhost:3004.

  7. Test with curl:

 curl  http://localhost:3004/api/welcome  

Project Structure

your-api/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ your_api/
โ”‚       โ”œโ”€โ”€ controllers/     ; Contains functions to handle incoming requests
โ”‚       โ”œโ”€โ”€ adapters/        ; Contains functions to adapt and process request data
โ”‚       โ”œโ”€โ”€ logic/           ; Contains functions defining the business logic and API routes
โ”œโ”€โ”€ test/
โ”‚   โ”œโ”€โ”€ integration/
โ”‚   โ”‚   โ””โ”€โ”€ integration_test.clj; Integration tests
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ”‚   โ””โ”€โ”€ unit_test.clj   ; Unit tests
โ”œโ”€โ”€ resources/
โ”‚   โ””โ”€โ”€ config.edn           ; Configuration file
โ”œโ”€โ”€ project.clj              ; Leiningen project file
โ””โ”€โ”€ README.md                ; Project documentation

License

This project is licensed under the MIT License.

Contributions

Contributions are welcome! Feel free to open issues or submit pull requests to improve this boilerplate.


Happy coding! ๐Ÿš€

boilerplate-clojure-service's People

Contributors

mguardarini avatar

Stargazers

 avatar  avatar

Watchers

 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.