diff --git a/README.md b/README.md
index 5ca8e88..abdc959 100644
--- a/README.md
+++ b/README.md
@@ -21,15 +21,23 @@ npm i @niseline/niseliff
Use NiseLiff sdk in your client app!
```tsx
-import { buildNiseLiff } from '@niseline/niseliff'
+import { buildNiseliff } from '@niseline/niseliff'
import React from 'react'
import ReactDOM from 'react-dom'
-const niseliff = buildNiseLiff()
+declare global {
+ interface Window {
+ liff: Liff
+ }
+}
-niseliff
+window.liff = buildNiseliff({
+ liffId: 'DUMMY_LIFF_ID',
+})
+
+window.liff
.init({
- liffId: 'DEFAULT_LIFF_ID', // You can use any value
+ liffId: 'DUMMY_LIFF_ID',
})
.then(() => {
ReactDOM.render(
@@ -49,23 +57,37 @@ npm i @niseline/niseliff
### Usage
+```ts
+// /path/to/config.ts
+
+export const env: 'local' | 'development' | 'staging' | 'production' = 'local'
+```
+
+```ts
+// /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
+```
+
```tsx
-import { buildNiseLiff } from '@niseline/niseliff'
+// /path/to/index.tsx
+
+import liff from '/path/to/liff'
import React from 'react'
import ReactDOM from 'react-dom'
-const niseliff = buildNiseLiff()
-
-niseliff
- .init({
- liffId: 'DEFAULT_LIFF_ID', // You can use any value
- })
- .then(() => {
- ReactDOM.render(
- Your client app,
- document.getElementById('root')
- )
- })
+liff.init({ liffId: 'DUMMY_LIFF_ID' }).then(() => {
+ ReactDOM.render(
+ Your client app,
+ document.getElementById('root')
+ )
+})
```
### Features
@@ -112,7 +134,7 @@ niseliff
```bash
docker run -d -p 3000:3000 dyoshikawa/niseline:latest
-curl http://localhost:3000/niseline/ping
+curl http://localhost:3000/niseline/api/ping
# => {"ping":"pong"}
```
@@ -130,7 +152,7 @@ services:
```bash
docker compose up -d
-curl http://localhost:3000/niseline/ping
+curl http://localhost:3000/niseline/api/ping
# => {"ping":"pong"}
```
@@ -138,7 +160,7 @@ curl http://localhost:3000/niseline/ping
```bash
curl --request POST \
- --url http://localhost:3000/niseline/users \
+ --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
diff --git a/api.http b/api.http
index 742336f..9a15e85 100644
--- a/api.http
+++ b/api.http
@@ -2,11 +2,11 @@
###
-GET {{ BASE_URL }}/niseline/ping
+GET {{ BASE_URL }}/niseline/api/ping
###
-POST {{ BASE_URL }}/niseline/users
+POST {{ BASE_URL }}/niseline/api/users
Content-Type: application/json
{
@@ -18,9 +18,8 @@ Content-Type: application/json
###
-GET {{ BASE_URL }}/niseline/users/me/_accessToken
+GET {{ BASE_URL }}/niseline/api/users/DEFAULT_USER
Content-Type: application/json
-Authorization: Bearer DEFAULT_USER_ACCESS_TOKEN
###
diff --git a/packages/niseliff-sdk/src/index.ts b/packages/niseliff-sdk/src/index.ts
index eb535b5..892a083 100644
--- a/packages/niseliff-sdk/src/index.ts
+++ b/packages/niseliff-sdk/src/index.ts
@@ -33,9 +33,8 @@ import { buildSendMessages } from './method/send-messages'
import { buildShareTargetPicker } from './method/share-target-picker'
import { ConsoleLogger, Logger } from './util/logger'
-export const buildNiseLiff = (params?: {
- clientEndpoint?: string
- authEndpoint?: string
+export const buildNiseliff = (params?: {
+ niseliffServerEndpoint?: string
liffId?: string
os?: 'ios' | 'android' | 'web' | undefined
language?: string
@@ -57,8 +56,8 @@ export const buildNiseLiff = (params?: {
| '_postMessage'
> => {
const logger: Logger = new ConsoleLogger()
- const clientEndpoint = params?.clientEndpoint ?? window.location.origin
- const authEndpoint = params?.authEndpoint ?? 'http://localhost:3000'
+ const niseliffServerEndpoint =
+ params?.niseliffServerEndpoint ?? 'http://localhost:3000'
const liffId = params?.liffId ?? 'DEFAULT_LIFF_ID'
const os = params?.os ?? 'web'
const language = params?.language ?? 'ja'
@@ -69,7 +68,7 @@ export const buildNiseLiff = (params?: {
return {
id: buildId(liffId),
ready: buildReady(),
- init: buildInit({ logger, clientEndpoint, authEndpoint }),
+ init: buildInit({ logger, niseliffServerEndpoint }),
getOS: buildGetOs(os),
getLanguage: buildGetLanguage(language),
getVersion: buildGetVersion(version),
diff --git a/packages/niseliff-sdk/src/method/init.ts b/packages/niseliff-sdk/src/method/init.ts
index db337ac..cfb14f0 100644
--- a/packages/niseliff-sdk/src/method/init.ts
+++ b/packages/niseliff-sdk/src/method/init.ts
@@ -1,87 +1,49 @@
import liff from '@line/liff'
-import { v4 as uuidV4 } from 'uuid'
+import { User } from '../type'
import { Logger } from '../util/logger'
export const buildInit =
({
logger,
- clientEndpoint,
- authEndpoint,
+ niseliffServerEndpoint,
}: {
logger: Logger
- clientEndpoint: string
- authEndpoint: string
+ niseliffServerEndpoint: string
}): typeof liff.init =>
- async (config): ReturnType => {
+ async (): ReturnType => {
logger.info('Init start')
/**
- * Check exists tokens
+ * Check user info
*/
- const accessToken = localStorage.getItem('ACCESS_TOKEN')
- const idToken = localStorage.getItem('ID_TOKEN')
- if (accessToken != null && idToken != null) {
- logger.info('Exists tokens')
-
- const fetchMeResult = await fetch(
- new URL('/niseline/users/me/_accessToken', authEndpoint).toString(),
- {
- headers: {
- Authorization: `Bearer ${accessToken}`,
- },
- }
- )
- if (!fetchMeResult.ok) {
- logger.error(
- 'Invalid response from GET /niseline/users/me/_accessToken'
- )
- return
- }
-
- const fetchMeResponseBody = await fetchMeResult.json()
- localStorage.setItem('MY_USER', JSON.stringify(fetchMeResponseBody))
- logger.info('Get and set my user info successfully')
+ const userStr = localStorage.getItem('MY_USER')
+ if (userStr != null) {
+ logger.info(`Get my user info successfully`)
return
}
- logger.info('Not exists tokens')
+ logger.info('Not exists my user info')
/**
- * Check state and authorization code
+ * Check userId
*/
const urlSearchParams = new URLSearchParams(window.location.search)
- const authorizationCode = urlSearchParams.get('code')
- const state = urlSearchParams.get('state')
- if (authorizationCode != null && state != null) {
- if (state !== localStorage.getItem('STATE')) {
- logger.error('Invalid state value')
- return
- }
-
- logger.info('Valid state value')
+ const userId = urlSearchParams.get('userId')
+ if (userId != null) {
const result = await fetch(
- new URL('/niseline/token', authEndpoint).toString(),
- {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- grantType: 'authorization_code',
- redirectUri: clientEndpoint,
- code: authorizationCode,
- }),
- }
+ new URL(
+ `/niseline/api/users/${userId}`,
+ niseliffServerEndpoint
+ ).toString()
)
if (!result.ok) {
- logger.error('Invalid response from POST /niseline/token')
+ logger.error(`Invalid response from GET /niseline/api/users/${userId}`)
return
}
- const json: { accessToken: string; idToken: string } = await result.json()
- localStorage.setItem('ACCESS_TOKEN', json.accessToken)
- localStorage.setItem('ID_TOKEN', json.idToken)
- logger.info('Get and set tokens successfully')
+ const json: User = await result.json()
+ localStorage.setItem('MY_USER', JSON.stringify(json))
+ logger.info('Get and set my user info successfully')
window.location.reload()
return
}
@@ -89,15 +51,6 @@ export const buildInit =
/**
* Start authorization flow
*/
- const newState = uuidV4()
- localStorage.setItem('STATE', newState)
- const url = new URL('/niseline/authorize', authEndpoint)
- url.search = new URLSearchParams({
- response_type: 'code',
- client_id: config.liffId,
- scope: 'default',
- redirect_uri: clientEndpoint,
- state: newState,
- }).toString()
+ const url = new URL('/niseline/authorize', niseliffServerEndpoint)
window.location.href = url.toString()
}
diff --git a/packages/niseliff-sdk/src/type.ts b/packages/niseliff-sdk/src/type.ts
new file mode 100644
index 0000000..d28848c
--- /dev/null
+++ b/packages/niseliff-sdk/src/type.ts
@@ -0,0 +1,9 @@
+export interface User {
+ id: string
+ name: string
+ picture: string
+ email: string
+ channelId: string
+ idToken: string
+ accessToken: string
+}
diff --git a/packages/sample-client-app/src/main.tsx b/packages/sample-client-app/src/main.tsx
index ff0fb38..948d543 100644
--- a/packages/sample-client-app/src/main.tsx
+++ b/packages/sample-client-app/src/main.tsx
@@ -1,5 +1,5 @@
import { Liff } from '@line/liff'
-import { buildNiseLiff } from '@niseline/niseliff'
+import { buildNiseliff } from '@niseline/niseliff'
import React from 'react'
import ReactDOM from 'react-dom'
import { App } from './app'
@@ -11,7 +11,7 @@ declare global {
}
}
-window.liff = buildNiseLiff() as Liff
+window.liff = buildNiseliff() as Liff
window.liff
.init({
diff --git a/packages/server/src/component/user/adapter/handler/authorize-fastify-handler.ts b/packages/server/src/component/user/adapter/handler/authorize-fastify-handler.ts
index a926cdb..1efce26 100644
--- a/packages/server/src/component/user/adapter/handler/authorize-fastify-handler.ts
+++ b/packages/server/src/component/user/adapter/handler/authorize-fastify-handler.ts
@@ -1,9 +1,6 @@
import { RouteHandlerMethod } from 'fastify'
export const buildAuthorizeFastifyHandler =
- (): RouteHandlerMethod => async (request, reply) => {
- const query = request.query as {
- state: string
- }
- reply.view('/template/authorize.ejs', { state: query.state })
+ (): RouteHandlerMethod => async (_, reply) => {
+ reply.view('/template/authorize.ejs')
}
diff --git a/packages/server/src/component/user/adapter/handler/debug-register-user-fastify-handler.ts b/packages/server/src/component/user/adapter/handler/debug-register-user-fastify-handler.ts
index bb81cab..e8361b3 100644
--- a/packages/server/src/component/user/adapter/handler/debug-register-user-fastify-handler.ts
+++ b/packages/server/src/component/user/adapter/handler/debug-register-user-fastify-handler.ts
@@ -22,7 +22,6 @@ export const buildDebugRegisterUserFastifyHandler =
channelId: body.channelId,
accessToken: body.accessToken,
idToken: body.idToken,
- authorizationCode: '',
})
reply.type('application/json').code(200)
diff --git a/packages/server/src/component/user/adapter/handler/find-user-by-access-token-fastify-handler.ts b/packages/server/src/component/user/adapter/handler/find-user-by-access-token-fastify-handler.ts
deleted file mode 100644
index 44f4193..0000000
--- a/packages/server/src/component/user/adapter/handler/find-user-by-access-token-fastify-handler.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { RouteHandlerMethod } from 'fastify'
-import { User } from '../../domain/entity'
-import {
- FindUserByAccessTokenUseCase,
- UserNotFoundError,
-} from '../../use-case/find-user-by-access-token-use-case'
-
-export const buildFindUserByAccessTokenFastifyHandler =
- ({
- findUserByAccessTokenUseCase,
- }: {
- findUserByAccessTokenUseCase: FindUserByAccessTokenUseCase
- }): RouteHandlerMethod =>
- async (request, reply) => {
- const [, accessToken] = request.headers.authorization!.split(' ')
- const user = await findUserByAccessTokenUseCase(accessToken)
- if (user instanceof UserNotFoundError) {
- reply.type('application/json').code(401).send()
- return
- }
-
- const responseBody: Pick = {
- id: user.id,
- name: user.name,
- picture: user.picture,
- email: user.email,
- }
- reply.type('application/json').code(200).send(responseBody)
- }
diff --git a/packages/server/src/component/user/adapter/handler/find-user-by-id-fastify-handler.ts b/packages/server/src/component/user/adapter/handler/find-user-by-id-fastify-handler.ts
new file mode 100644
index 0000000..081b3ba
--- /dev/null
+++ b/packages/server/src/component/user/adapter/handler/find-user-by-id-fastify-handler.ts
@@ -0,0 +1,22 @@
+import { RouteHandlerMethod } from 'fastify'
+import {
+ FindUserUseCase,
+ UserNotFoundError,
+} from '../../use-case/find-user-use-case'
+
+export const buildFindUserByIdFastifyHandler =
+ ({
+ findUserUseCase,
+ }: {
+ findUserUseCase: FindUserUseCase
+ }): RouteHandlerMethod =>
+ async (request, reply) => {
+ const { id } = request.params as { id: string }
+ const user = await findUserUseCase(id)
+ if (user instanceof UserNotFoundError) {
+ reply.type('application/json').code(401).send()
+ return
+ }
+
+ reply.type('application/json').code(200).send(user)
+ }
diff --git a/packages/server/src/component/user/adapter/handler/login-fastify-handler.ts b/packages/server/src/component/user/adapter/handler/login-fastify-handler.ts
index 5ba616e..857002e 100644
--- a/packages/server/src/component/user/adapter/handler/login-fastify-handler.ts
+++ b/packages/server/src/component/user/adapter/handler/login-fastify-handler.ts
@@ -12,18 +12,16 @@ export const buildLoginFastifyHandler =
async (request, reply) => {
const body = request.body as {
userId: string
- state: string
}
- const authorizationCode = await loginUseCase(body.userId)
- if (authorizationCode instanceof UserNotFoundError) {
+ const user = await loginUseCase(body.userId)
+ if (user instanceof UserNotFoundError) {
reply.redirect(302, '/niseline/authorize')
return
}
const url = new URL(clientEndpoint)
url.search = new URLSearchParams({
- code: authorizationCode,
- state: body.state,
+ userId: user.id,
}).toString()
reply.redirect(302, url.toString())
}
diff --git a/packages/server/src/component/user/adapter/handler/token-fastify-handler.ts b/packages/server/src/component/user/adapter/handler/token-fastify-handler.ts
deleted file mode 100644
index 9d150a2..0000000
--- a/packages/server/src/component/user/adapter/handler/token-fastify-handler.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { RouteHandlerMethod } from 'fastify'
-import {
- FindUserByAuthorizationCodeUseCase,
- UserNotFoundError,
-} from '../../use-case/find-user-by-authorization-code-use-case'
-
-export const buildTokenFastifyHandler =
- ({
- findUserByAuthorizationTokenUseCase,
- }: {
- findUserByAuthorizationTokenUseCase: FindUserByAuthorizationCodeUseCase
- }): RouteHandlerMethod =>
- async (request, reply) => {
- const body = request.body as {
- grantType: string
- redirectUri: string
- code: string
- }
-
- const user = await findUserByAuthorizationTokenUseCase(body.code)
- if (user instanceof UserNotFoundError) {
- reply.type('application/json').code(401).send({
- message: 'Invalid authorization code',
- })
- return
- }
-
- reply.type('application/json').code(200).send({
- accessToken: user.accessToken,
- idToken: user.idToken,
- })
- }
diff --git a/packages/server/src/component/user/adapter/repository/user-repository.ts b/packages/server/src/component/user/adapter/repository/user-repository.ts
index df6ce94..223de06 100644
--- a/packages/server/src/component/user/adapter/repository/user-repository.ts
+++ b/packages/server/src/component/user/adapter/repository/user-repository.ts
@@ -51,20 +51,6 @@ export class UserLowRepository implements UserRepository {
return userRecord
}
- async findByAuthorizationCode(
- authorizationCode: string
- ): Promise {
- await this.low.read()
- const userRecord: UserRecord | undefined = this.low.data?.find(
- (r) => r.authorizationCode === authorizationCode
- )
- if (userRecord == null) {
- return undefined
- }
-
- return userRecord
- }
-
async save(user: User): Promise {
await this.low.read()
this.low.data = this.low.data!.concat(user)
diff --git a/packages/server/src/component/user/domain/entity.ts b/packages/server/src/component/user/domain/entity.ts
index 9b452c1..d28848c 100644
--- a/packages/server/src/component/user/domain/entity.ts
+++ b/packages/server/src/component/user/domain/entity.ts
@@ -6,5 +6,4 @@ export interface User {
channelId: string
idToken: string
accessToken: string
- authorizationCode: string
}
diff --git a/packages/server/src/component/user/domain/repository.ts b/packages/server/src/component/user/domain/repository.ts
index 2af3a6c..72e5b18 100644
--- a/packages/server/src/component/user/domain/repository.ts
+++ b/packages/server/src/component/user/domain/repository.ts
@@ -4,6 +4,5 @@ export interface UserRepository {
find(id: string): Promise
findByAccessToken(accessToken: string): Promise
findByIdToken(idToken: string): Promise
- findByAuthorizationCode(authorizationCode: string): Promise
save(user: User): Promise
}
diff --git a/packages/server/src/component/user/use-case/find-user-by-authorization-code-use-case.ts b/packages/server/src/component/user/use-case/find-user-by-authorization-code-use-case.ts
deleted file mode 100644
index 502db97..0000000
--- a/packages/server/src/component/user/use-case/find-user-by-authorization-code-use-case.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { User } from '../domain/entity'
-import { UserRepository } from '../domain/repository'
-
-export class UserNotFoundError extends Error {}
-
-export type FindUserByAuthorizationCodeUseCase = (
- authorizationCode: string
-) => Promise
-
-export const buildFindUserByAuthorizationCodeUseCase =
- ({
- userRepository,
- }: {
- userRepository: UserRepository
- }): FindUserByAuthorizationCodeUseCase =>
- async (authorizationCode: string) => {
- const user = await userRepository.findByAuthorizationCode(authorizationCode)
- if (user == null) {
- return new UserNotFoundError()
- }
-
- return user
- }
diff --git a/packages/server/src/component/user/use-case/login-use-case.ts b/packages/server/src/component/user/use-case/login-use-case.ts
index 4484be2..fb641ab 100644
--- a/packages/server/src/component/user/use-case/login-use-case.ts
+++ b/packages/server/src/component/user/use-case/login-use-case.ts
@@ -1,18 +1,14 @@
import { GenerateUuid } from '../../../util/uuid'
+import { User } from '../domain/entity'
import { UserRepository } from '../domain/repository'
-type AuthorizationCode = string
-
export class UserNotFoundError extends Error {}
-export type LoginUseCase = (
- userId: string
-) => Promise
+export type LoginUseCase = (userId: string) => Promise
export const buildLoginUseCase =
({
userRepository,
- generateUuid,
}: {
userRepository: UserRepository
generateUuid: GenerateUuid
@@ -23,7 +19,6 @@ export const buildLoginUseCase =
return new UserNotFoundError()
}
- const uuid = generateUuid()
- await userRepository.save({ ...user, authorizationCode: uuid })
- return uuid
+ await userRepository.save({ ...user })
+ return user
}
diff --git a/packages/server/src/di/bootstrap.ts b/packages/server/src/di/bootstrap.ts
index 6df194b..bb94638 100644
--- a/packages/server/src/di/bootstrap.ts
+++ b/packages/server/src/di/bootstrap.ts
@@ -12,17 +12,15 @@ import { buildSendReplyMessageUseCase } from '../component/message/use-case/send
import { buildAuthorizeFastifyHandler } from '../component/user/adapter/handler/authorize-fastify-handler'
import { buildDebugPingFastifyHandler } from '../component/user/adapter/handler/debug-ping-fastify-handler'
import { buildDebugRegisterUserFastifyHandler } from '../component/user/adapter/handler/debug-register-user-fastify-handler'
-import { buildFindUserByAccessTokenFastifyHandler } from '../component/user/adapter/handler/find-user-by-access-token-fastify-handler'
+import { buildFindUserByIdFastifyHandler } from '../component/user/adapter/handler/find-user-by-id-fastify-handler'
import { buildShowUserComponentHandler } from '../component/user/adapter/handler/find-user-component-handler'
import { buildFriendshipStatusFastifyHandler } from '../component/user/adapter/handler/get-friendship-status-fastify-handler'
import { buildGetUserProfileFastifyHandler } from '../component/user/adapter/handler/get-user-profile-fastify-handler'
import { buildLoginFastifyHandler } from '../component/user/adapter/handler/login-fastify-handler'
-import { buildTokenFastifyHandler } from '../component/user/adapter/handler/token-fastify-handler'
import { buildVerifyAccessTokenFastifyHandler } from '../component/user/adapter/handler/verify-access-token-fastify-handler'
import { buildVerifyIdTokenFastifyHandler } from '../component/user/adapter/handler/verify-id-token-fastify-handler'
import { UserLowRepository } from '../component/user/adapter/repository/user-repository'
import { buildFindUserByAccessTokenUseCase } from '../component/user/use-case/find-user-by-access-token-use-case'
-import { buildFindUserByAuthorizationCodeUseCase } from '../component/user/use-case/find-user-by-authorization-code-use-case'
import { buildFindUserByIdTokenUseCase } from '../component/user/use-case/find-user-by-id-token-use-case'
import { buildFindUserUseCase } from '../component/user/use-case/find-user-use-case'
import { buildLoginUseCase } from '../component/user/use-case/login-use-case'
@@ -112,13 +110,6 @@ export const bootstrap = (): Container => {
generateUuid: c.get(DI_TYPE.GENERATE_UUID),
})
)
- container
- .bind(DI_TYPE.FIND_USER_BY_AUTHORIZATION_CODE_USE_CASE)
- .toDynamicValue(({ container: c }) =>
- buildFindUserByAuthorizationCodeUseCase({
- userRepository: c.get(DI_TYPE.USER_COMPONENT_USER_REPOSITORY),
- })
- )
container
.bind(DI_TYPE.FIND_USER_BY_ACCESS_TOKEN_USE_CASE)
.toDynamicValue(({ container: c }) =>
@@ -182,21 +173,10 @@ export const bootstrap = (): Container => {
})
)
container
- .bind(DI_TYPE.TOKEN_FASTIFY_HANDLER)
+ .bind(DI_TYPE.FIND_USER_BY_ID_FASTIFY_HANDLER)
.toDynamicValue(({ container: c }) =>
- buildTokenFastifyHandler({
- findUserByAuthorizationTokenUseCase: c.get(
- DI_TYPE.FIND_USER_BY_AUTHORIZATION_CODE_USE_CASE
- ),
- })
- )
- container
- .bind(DI_TYPE.FIND_USER_BY_ACCESS_TOKEN_FASTIFY_HANDLER)
- .toDynamicValue(({ container: c }) =>
- buildFindUserByAccessTokenFastifyHandler({
- findUserByAccessTokenUseCase: c.get(
- DI_TYPE.FIND_USER_BY_ACCESS_TOKEN_USE_CASE
- ),
+ buildFindUserByIdFastifyHandler({
+ findUserUseCase: c.get(DI_TYPE.FIND_USER_USE_CASE),
})
)
diff --git a/packages/server/src/di/type.ts b/packages/server/src/di/type.ts
index b41fd0d..3a2877e 100644
--- a/packages/server/src/di/type.ts
+++ b/packages/server/src/di/type.ts
@@ -18,8 +18,6 @@ export const DI_TYPE = {
REGISTER_USER_USE_CASE: 'REGISTER_USER_USER_CASE',
LOGIN_USE_CASE: 'LOGIN_USE_CASE',
FIND_USER_USE_CASE: 'FIND_USER_USE_CASE',
- FIND_USER_BY_AUTHORIZATION_CODE_USE_CASE:
- 'FIND_USER_BY_AUTHORIZATION_CODE_USE_CASE',
FIND_USER_BY_ACCESS_TOKEN_USE_CASE: 'FIND_USER_BY_ACCESS_TOKEN_USE_CASE',
FIND_USER_BY_ID_TOKEN_USE_CASE: 'FIND_USER_BY_ID_TOKEN_USE_CASE',
DEBUG_PING_HANDLER: 'DEBUG_PING_HANDLER',
@@ -32,9 +30,7 @@ export const DI_TYPE = {
FIND_USER_COMPONENT_HANDLER: 'FIND_USER_COMPONENT_HANDLER',
AUTHORIZE_FASTIFY_HANDLER: 'AUTHORIZE_FASTIFY_HANDLER',
LOGIN_FASTIFY_HANDLER: 'LOGIN_FASTIFY_HANDLER',
- TOKEN_FASTIFY_HANDLER: 'TOKEN_FASTIFY_HANDLER',
- FIND_USER_BY_ACCESS_TOKEN_FASTIFY_HANDLER:
- 'FIND_USER_BY_ACCESS_TOKEN_FASTIFY_HANDLER',
+ FIND_USER_BY_ID_FASTIFY_HANDLER: 'FIND_USER_BY_ID_FASTIFY_HANDLER',
// Message Component
MESSAGE_COMPONENT_USER_REPOSITORY: 'MESSAGE_COMPONENT_USER_REPOSITORY',
diff --git a/packages/server/src/main.ts b/packages/server/src/main.ts
index b0054f7..9c36229 100644
--- a/packages/server/src/main.ts
+++ b/packages/server/src/main.ts
@@ -25,18 +25,16 @@ const container = bootstrap()
* NiseLine original
*/
fastify.get(
- '/niseline/ping',
+ '/niseline/api/ping',
container.get(DI_TYPE.DEBUG_PING_HANDLER)
)
fastify.post(
- '/niseline/users',
+ '/niseline/api/users',
container.get(DI_TYPE.DEBUG_REGISTER_USER_HANDLER)
)
fastify.get(
- '/niseline/users/me/_accessToken',
- container.get(
- DI_TYPE.FIND_USER_BY_ACCESS_TOKEN_FASTIFY_HANDLER
- )
+ '/niseline/api/users/:id',
+ container.get(DI_TYPE.FIND_USER_BY_ID_FASTIFY_HANDLER)
)
fastify.get(
'/niseline/authorize',
@@ -46,10 +44,6 @@ fastify.post(
'/niseline/login',
container.get(DI_TYPE.LOGIN_FASTIFY_HANDLER)
)
-fastify.post(
- '/niseline/token',
- container.get(DI_TYPE.TOKEN_FASTIFY_HANDLER)
-)
/**
* Login API
diff --git a/packages/server/src/util/db/lowdb.ts b/packages/server/src/util/db/lowdb.ts
index 3e3aafd..edf7ef7 100644
--- a/packages/server/src/util/db/lowdb.ts
+++ b/packages/server/src/util/db/lowdb.ts
@@ -22,7 +22,6 @@ export const initLowDb = () => {
channelId: 'DEFAULT_CHANNEL',
accessToken: 'DEFAULT_USER_ACCESS_TOKEN',
idToken: 'DEFAULT_USER_ID_TOKEN',
- authorizationCode: '',
},
]
fs.writeFileSync('./tmp/users.json', JSON.stringify(userJson, null, 2))
diff --git a/packages/server/template/authorize.ejs b/packages/server/template/authorize.ejs
index b4f3317..989def6 100644
--- a/packages/server/template/authorize.ejs
+++ b/packages/server/template/authorize.ejs
@@ -34,12 +34,6 @@
name="userId"
/>
-