Skip to content

Commit b968704

Browse files
committed
update api to add setToken method
1 parent 4bdfd5e commit b968704

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/api/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ export const routes = {
9595
)
9696
return spotifyAccessToken
9797
},
98+
99+
async setSpotifyToken(id: string, token: SpotifyAccessToken) {
100+
const tokensTable = em.getRepository(Token)
101+
102+
const oldToken = await tokensTable.findOne(parseInt(id))
103+
if (oldToken) {
104+
oldToken.spotifyAccessToken = JSON.stringify(token)
105+
await em.flush()
106+
}
107+
return
108+
}
98109
}
99110

100111
export const init = async (port: number) => {

0 commit comments

Comments
 (0)