GithubHelp home page GithubHelp logo

evenchange4 / micro-medium-api Goto Github PK

View Code? Open in Web Editor NEW
140.0 3.0 18.0 225 KB

Microservice for fetching the latest posts of Medium with GraphQL.

Home Page: https://micro-medium-api.now.sh/graphiql

License: MIT License

JavaScript 86.26% Shell 13.74%
microservice micro medium now zeit graphql graphql-tools apollo-server pkg docker

micro-medium-api's Introduction

Micro-medium-api

Microservice for fetching the latest posts of Medium with GraphQL.

Further reading: [中文] Microservice 產品交付 - Dockerize 與 Zeit JavaScript 跨平台解決方案

Travis Codecov Status Github Tag node

Dependency Status devDependency Status peerDependency Status Greenkeeper badge prettier license

Feature

  • Use GraphQL.
  • Dataloader for per-request memory cache.
  • Rate-limiting 1 requests per sec.

How To Use

a. Deploy to Now.sh

One click deploys to △ now

Deploy to now

b. Binary executable

Download from GitHub latest release.

$ ORIGIN=$YOUR_DOMAIN \
  ./micro-medium-api-macos --port $PORT

Note: You can run it without Node.js installed.

c. Docker image

Pull from dockerhub.

Docker Automated build Docker Pulls Docker Size

$ docker pull evenchange4/micro-medium-api:latest
$ docker run --rm -it \
  -p $PORT:3000 \
  -e "ORIGIN=YOUR_DOMAIN" \
  evenchange4/micro-medium-api:latest

d. NPM CLI

Install from npm.

npm downloads npm

$ npm i micro-medium-api -g
 
$ ORIGIN=$YOUR_DOMAIN \
  micro-medium-api --port $PORT

Note: You should use Node.js >= 8 .

API

Environment variables

ENV Required Default Description
ORIGIN * Setup access-control-allow-origin for CORS.

CLI arguments

$ micro-medium-api --help
Usage: micro-medium-api <command> [options]
 
Options:
  -p, --port     HTTP server PORT                                [default: 3000]
  -h, --help     Show help                                             [boolean]
  -v, --version  Show version number                                   [boolean]

GraphQL endpoint

  • [GET] /graphql
  • [POST] /graphql

Demo

Note: You should deploy your own service for production usage.

Technology Stacks

  • Micro: Asynchronous HTTP microservices.
  • Micro-router: A tiny and functional router for Zeit's Micro.
  • Micro-ratelimit: Rate-limiting middleware for micro.
  • Graphql-tools: 🔧 Build and mock your GraphQL.js schema using the schema language.
  • Graphql-server-micro: 🌍 GraphQL server
  • Dataloader: DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a consistent API over various backends and reduce requests to those backends via batching and caching.
  • Dockerhub: Automatically deploy docker image.
  • Now.sh: Realtime global deployments
  • Pkg: Package your Node.js project into an executable
  • Travis: CI

Developer Guide

Requirements

  • node >= 8.5.0
  • npm >= 5.3.0
  • yarn >= 1.0.2
$ git clone https://github.com/evenchange4/micro-medium-api.git
$ yarn install --pure-lockfile

$ yarn run dev # dev server
$ yarn start   # prod server
$ yarn run pkg # output binary files

Test

$ yarn run format
$ yarn run eslint
$ yarn run test:watch

Docker

$ docker build -t micro-medium-api .

# Push to dockerhub
$ git push

Note: Multi-stage builds are a new feature in Docker 17.05.

Github release / NPM release

$ npm version patch
$ git push

Inspiration

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ yarn run test).

MIT: http://michaelhsu.mit-license.org

micro-medium-api's People

Contributors

evenchange4 avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

micro-medium-api's Issues

Content attributes?

I would love to see the full text of an article included in Content. Having just subtitle is redundant since that's already included on Post.

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.