Add OAuth controller

This commit is contained in:
Alex Gleason
2023-03-04 21:36:53 -06:00
parent 8ed662321d
commit b36b8ea7d2
3 changed files with 29 additions and 3 deletions

22
src/api/oauth.ts Normal file
View File

@@ -0,0 +1,22 @@
import { validator, z } from '@/deps.ts';
const createTokenSchema = z.object({
password: z.string(),
});
const createTokenController = validator('json', (value, c) => {
const result = createTokenSchema.safeParse(value);
if (result.success) {
return c.json({
access_token: result.data.password,
token_type: 'Bearer',
scope: 'read write follow push',
created_at: Math.floor(new Date().getTime() / 1000),
});
} else {
return c.json({ error: 'Invalid request' }, 400);
}
});
export { createTokenController };