Giter Club home page Giter Club logo

fetch-images's Introduction

Fetch Images

How to run

Prerequisite

  • node.js >= 18
  • docker
  • docker-compose 3

Steps

Install deps

npm i

Start up docker services

docker-compose up -d 

Generate .env

cp .env.example .env

Note: You have to provide those API_KEY and JWT_SECRET in the .env file.

Also, you can set DISABLE_AUTH to arbitrary value to disable authentication, so you dont have to provide auth token anymore.

Start the app

npm run start

Usage

Graphql

Once the app is started, can goto http://localhost:3000/graphql-ide

There is a web-GUI for testing graphql query.

Example query

{
  images(key: "cat") {
    image_ID
    thumbnails
    preview
    title
    source
    tags
  }
}

Feel free to replace "cat" to any keyword

HTTP APIs

For playing with HTTP APIs, here are some good tools:

  • curl
  • postman (recommended)

API Endpoints

Host: http://localhost:3000

POST /users

This API is for signing up.

Body

  • username string required
  • password string required

POST /users/login

This API is for logging in.

Body

  • username string required
  • password string required

Returns

  • access_token string
    • a token for accessing /images API, expires in 10 mins

GET /images

This is the main API which is providing images from various 3rd party image lib.

Headers

  • Authorization string required
    • plz send token in this format Authorization: Bearer YOUR_TOKEN_HERE
    • you can however, disable the auth by setting DISABLE_AUTH to any value in .env, so you dont have to provide access token to use this API.

Query String

  • key string required
    • a term for searching related images. e.g. cat

Returns

  • images object[]
    • object props
      • image_ID string
      • thumbnails string - thumbnail URL
      • preview string - Image URL
      • title string
      • source string - which lib is this image from
      • tags string[] - associated tags

fetch-images's People

Contributors

kh931623 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.