Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
/ niseline Public archive

NiseLine is inspired by LocalStack. Goal of this tool is to create a mock service for LINE.

License

Notifications You must be signed in to change notification settings

cm-dyoshikawa/niseline

Repository files navigation

NiseLine

NiseLine

NiseLine is inspired by LocalStack. Goal of this tool is to create a mock service for LINE.

Getting Started

Launch NiseLine server.

docker run -d -p 3000:3000 dyoshikawa/niseline:latest

And install NiseLiff SDK.

npm i @niseline/niseliff

Use NiseLiff sdk in your client app!

import { buildNiseliff } from '@niseline/niseliff'
import React from 'react'
import ReactDOM from 'react-dom'

declare global {
  interface Window {
    liff: Liff
  }
}

window.liff = buildNiseliff({
  liffId: 'DUMMY_LIFF_ID',
})

window.liff
  .init({
    liffId: 'DUMMY_LIFF_ID',
  })
  .then(() => {
    ReactDOM.render(
      <React.StrictMode>Your client app</React.StrictMode>,
      document.getElementById('root')
    )
  })

NiseLiff SDK

Setup

npm i @niseline/niseliff

Usage

// /path/to/config.ts

export const env: 'local' | 'development' | 'staging' | 'production' = 'local'
// /path/to/liff.ts

import * as config from '/path/to/config'
import realLiff from '@line/liff'
import { buildNiseliff } from '@niseline/niseliff'

const liff =
  config.env === 'local' ? buildNiseliff({ liffId: 'DUMMY_LIFF_ID' }) : realLiff
export default liff
// /path/to/index.tsx

import liff from '/path/to/liff'
import React from 'react'
import ReactDOM from 'react-dom'

liff.init({ liffId: 'DUMMY_LIFF_ID' }).then(() => {
  ReactDOM.render(
    <React.StrictMode>Your client app</React.StrictMode>,
    document.getElementById('root')
  )
})

Features

NiseLine Server

Setup

Docker

docker run -d -p 3000:3000 dyoshikawa/niseline:latest
curl http://localhost:3000/niseline/api/ping
# => {"ping":"pong"}

Docker Compose

# docker-compose.yml
version: '3'
services:
  niseline:
    image: dyoshikawa/niseline:latest
    ports:
      - 3000:3000
docker compose up -d
curl http://localhost:3000/niseline/api/ping
# => {"ping":"pong"}

Usage

curl --request POST \
  --url http://localhost:3000/niseline/api/users \
  --header 'content-type: application/json' \
  --data '{"id": "FOO_ID","name": "Foo","picture": "http://example.com/foo.jpg","email": "[email protected]"}'
# => null

curl -v -X POST 'http://localhost:3000/oauth2/v2.1/verify' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'id_token=FOO_ID' \
  --data-urlencode 'client_id=1234567890'
# => {"iss":"https://example.com","sub":"FOO_ID","aud":"1234567890","exp":1504169092,"iat":1504263657,"nonce":"0987654asdf","amr":["pwd"],"name":"Foo","picture":"http://example.com/foo.jpg","email":"[email protected]"}

Features

Login API

Messaging API