Giter Site home page Giter Site logo

thestuti / aot-api Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 5.0 325 KB

A free API to retrieve some quotes of Attack On Titan!

Home Page: https://aot-quotes-api.herokuapp.com/

JavaScript 72.09% Procfile 0.10% HTML 19.50% CSS 8.26% Shell 0.05%
api attackontitan aot expressjs nodejs quotes ejs hacktoberfest open-source

aot-api's Introduction

Attack On Titan quotes API

A simple API to retrieve some quotes of Attack On Titan

🌐 Website and demo: https://aot-quotes-api.herokuapp.com/

Check out python version of this project by Nishant Sensei : https://github.com/thenishantsapkota/aot-api-py

Installation

git clone https://github.com/thestuti/aot-api
cd aot-api
  • create .env file, add variables according to .env.example
cp .env.example .env
npm install
npm run dev

Production host

https://aot-quotes-api.herokuapp.com/

API

GET /random

Get a random quote in this format:

https://aot-quotes-api.herokuapp.com/random

{
  "id": 26,
  "quote": "Everyone can make a choice after they have learned what it will result in. It is so easy to say we should have done it this way afterwards. But you can’t know what your choice will result in before actually choosing."
}

GET /random?count={number}

Returns an array with {number} quotes e.g. GET /random?count=5.

https://aot-quotes-api.herokuapp.com/random/5/

[
  {
    "id": 61,
    "quote": "Asking me for compassion is mistaken. After all I have no heart or time to spare."
  },
  {
    "id": 41,
    "quote": "Some scouts’ lives are more valuable than others, only those dumb enough to acknowledge that join us."
  },
  {
    "id": 23,
    "quote": "I don’t like the terms good person or bad person because it’s impossible to be entirely good to everyone, or entirely bad to everyone. To some, you are a good person, while to others you are a bad person."
  },
  {
    "id": 27,
    "quote": "I was, I am, and I remain a soldier, sworn to devote my heart and soul to the restoration of humankind. There is no greater glory than dying for that belief!"
  },
  {
    "id": 20,
    "quote": "To surpass monsters, you must be willing to abandon your humanity."
  }
]

Contributing

If you want to add some quotes, just add them in quotes/quotes.js file and do a pull request !

Contributors

Anuj aka TheCoolDev
Dipshan

TODO

  • Better UI
  • Make site responsive for mobile
  • Add authors in API

aot-api's People

Contributors

bekoool avatar dependabot[bot] avatar dibashthapa avatar nabinbhatt avatar neeraj319 avatar rudrakshkarpe avatar thecasanovaa avatar thenishantsapkota avatar thestuti avatar washbin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

aot-api's Issues

Code Review

1

When you define routes like this, the second parameter is the handler.

aot-api/index.js

Lines 24 to 26 in d66ee8e

app.get('/', (req, res) => {
res.render('index', {amount: numOfQuotes()})
})

But you have a separate file called handlers.js which isn't directly handling the response. It'd be better if you did something like this.

 app.get('/', homepageHandler)

and, all the logic of handling the route goes inside the homepageHandler.

2

port = process.env.PORT || 3000

Never ever do this when you build an application.

For example, let me consider you're hosting this application in a server and the server expects you to run your app in port 4050. Now, your app will be working perfectly fine if you forgot to provide the value of PORT . But you'll not be able to access since you've a defeault value of 3000 instead of 4050. Throw a error instead when value is not provided.

Netlify Deployment

image
On netlify

image
On localhost

There is difference in 'How to contribute' section

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.