Skip to content

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 by Docker image.

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'importReactfrom'react'importReactDOMfrom'react-dom'constliff=buildNiseliff({liffId: 'DUMMY_LIFF_ID',})liff.init({liffId: 'DUMMY_LIFF_ID',}).then(()=>{ReactDOM.render(<React.StrictMode>Your client app</React.StrictMode>,document.getElementById('root'))})

NiseLiff SDK

Setup

Install @niseline/niseliff.

npm i @niseline/niseliff

Usage

With npm package of LIFF SDK

You can use with npm package of LIFF SDK. Switch between the real LIFF SDK and the NiseLiff SDK for each environment. In this example, the NiseLiff SDK is used only in the local environment.

// /path/to/config.tsexportconstenv: 'local'|'development'|'staging'|'production'='local'
// /path/to/liff.tsimport*asconfigfrom'/path/to/config'importrealLiff,{Liff}from'@line/liff'import{buildNiseliff}from'@niseline/niseliff'constliff=config.env==='local' ? buildNiseliff({liffId: 'DUMMY_LIFF_ID'}) : realLiffexportdefaultliff
// /path/to/index.tsximportlifffrom'/path/to/liff'importReactfrom'react'importReactDOMfrom'react-dom'liff.init({liffId: 'DUMMY_LIFF_ID'}).then(()=>{ReactDOM.render(<React.StrictMode>Your client app</React.StrictMode>,document.getElementById('root'))})

With CDN of LIFF SDK

You can also use with CDN of LIFF SDK. If you use typescript, it is recommended that you install the @line/liff package. The actual runtime is a CDN, but the type definitions are available from the npm package.

// /path/to/config.tsexportconstenv: 'local'|'development'|'staging'|'production'='local'
// /path/to/index.tsximport*asconfigfrom'/path/to/config'import{Liff}from'@line/liff'import{buildNiseliff}from'@niseline/niseliff'importReactfrom'react'importReactDOMfrom'react-dom'declare global {varliff: Liff}if(config.env==='local'){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'))})

Features

NiseLine Server

Setup

Pull and run dyoshikawa/niseline.

Docker

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

Docker Compose

# docker-compose.ymlversion: '3'services:
niseline:
image: dyoshikawa/niseline:latestports:
- 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": "foo@example.com"}'# => 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":"foo@example.com"}

Features

Login API

Messaging API

About

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

Topics

Resources

Stars

9 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages