-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
/runtime-safe
export to all packages
- Loading branch information
Showing
18 changed files
with
396 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { initUntypeable } from "untypeable"; | ||
|
||
import { ItemSchema, ItemParamsSchema } from "./items/items.validators"; | ||
import { | ||
AskStoriesSchema, | ||
BestStoriesSchema, | ||
JobStoriesSchema, | ||
LiveDataParamsSchema, | ||
MaxItemIdSchema, | ||
NewStoriesSchema, | ||
ShowStoriesSchema, | ||
TopStoriesSchema, | ||
UpdatesSchema, | ||
} from "./liveData/liveData.validators"; | ||
import { UserSchema, UserParamsSchema } from "./users/users.validators"; | ||
|
||
const u = initUntypeable(); | ||
|
||
export const hackerNewsSafeRouter = u.router({ | ||
"/v0/askstories.json": u.input(LiveDataParamsSchema).output(AskStoriesSchema), | ||
"/v0/beststories.json": u | ||
.input(LiveDataParamsSchema) | ||
.output(BestStoriesSchema), | ||
"/v0/item/:id.json": u.input(ItemParamsSchema).output(ItemSchema), | ||
"/v0/jobstories.json": u.input(LiveDataParamsSchema).output(JobStoriesSchema), | ||
"/v0/maxitem.json": u.input(LiveDataParamsSchema).output(MaxItemIdSchema), | ||
"/v0/newstories.json": u.input(LiveDataParamsSchema).output(NewStoriesSchema), | ||
"/v0/showstories.json": u | ||
.input(LiveDataParamsSchema) | ||
.output(ShowStoriesSchema), | ||
"/v0/topstories.json": u.input(LiveDataParamsSchema).output(TopStoriesSchema), | ||
"/v0/updates.json": u.input(LiveDataParamsSchema).output(UpdatesSchema), | ||
"/v0/user/:id.json": u.input(UserParamsSchema).output(UserSchema), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { initUntypeable } from "untypeable"; | ||
|
||
import { | ||
AlbumSchema, | ||
AlbumParamsSchema, | ||
AlbumsSchema, | ||
AlbumsParamsSchema, | ||
CreatedAlbumSchema, | ||
CreatedAlbumParamsSchema, | ||
} from "./album/album.validators"; | ||
import { | ||
CommentSchema, | ||
CommentParamsSchema, | ||
CommentsSchema, | ||
CommentsParamsSchema, | ||
CreatedCommentSchema, | ||
CreatedCommentParamsSchema, | ||
} from "./comment/comment.validators"; | ||
import { | ||
CreatedPhotoSchema, | ||
CreatedPhotoParamsSchema, | ||
PhotoSchema, | ||
PhotoParamsSchema, | ||
PhotosSchema, | ||
PhotosParamsSchema, | ||
} from "./photo/photo.validators"; | ||
import { | ||
CreatedPostSchema, | ||
CreatedPostParamsSchema, | ||
PostSchema, | ||
PostParamsSchema, | ||
PostsSchema, | ||
PostsParamsSchema, | ||
} from "./post/post.validators"; | ||
import { | ||
CreatedTodoSchema, | ||
CreatedTodoParamsSchema, | ||
TodoSchema, | ||
TodoParamsSchema, | ||
TodosSchema, | ||
TodosParamsSchema, | ||
} from "./todo/todo.validators"; | ||
import { | ||
CreatedUserSchema, | ||
CreatedUserParamsSchema, | ||
UserSchema, | ||
UserParamsSchema, | ||
UsersSchema, | ||
UsersParamsSchema, | ||
} from "./user/user.validators"; | ||
|
||
const u = initUntypeable(); | ||
|
||
const allResources = u.pushArg<"GET" | "POST">(); | ||
const allResourcesRouter = allResources.router({ | ||
"/albums": { | ||
GET: allResources.input(AlbumsParamsSchema).output(AlbumsSchema), | ||
POST: allResources | ||
.input(CreatedAlbumParamsSchema) | ||
.output(CreatedAlbumSchema), | ||
}, | ||
"/comments": { | ||
GET: allResources.input(CommentsParamsSchema).output(CommentsSchema), | ||
POST: allResources | ||
.input(CreatedCommentParamsSchema) | ||
.output(CreatedCommentSchema), | ||
}, | ||
"/photos": { | ||
GET: allResources.input(PhotosParamsSchema).output(PhotosSchema), | ||
POST: allResources | ||
.input(CreatedPhotoParamsSchema) | ||
.output(CreatedPhotoSchema), | ||
}, | ||
"/posts": { | ||
GET: allResources.input(PostsParamsSchema).output(PostsSchema), | ||
POST: allResources.input(CreatedPostParamsSchema).output(CreatedPostSchema), | ||
}, | ||
"/todos": { | ||
GET: allResources.input(TodosParamsSchema).output(TodosSchema), | ||
POST: allResources.input(CreatedTodoParamsSchema).output(CreatedTodoSchema), | ||
}, | ||
"/users": { | ||
GET: allResources.input(UsersParamsSchema).output(UsersSchema), | ||
POST: allResources.input(CreatedUserParamsSchema).output(CreatedUserSchema), | ||
}, | ||
}); | ||
|
||
const singleResource = u.pushArg<"GET" | "PUT" | "PATCH" | "DELETE">(); | ||
const singleResourceRouter = singleResource.router({ | ||
"/albums/:id": { | ||
GET: singleResource.input(AlbumParamsSchema).output(AlbumSchema), | ||
}, | ||
"/albums/:id/comments": { | ||
GET: singleResource.input(AlbumParamsSchema).output(CommentsSchema), | ||
}, | ||
"/comments/:id": { | ||
GET: singleResource.input(CommentParamsSchema).output(CommentSchema), | ||
}, | ||
"/comments/:id/comments": { | ||
GET: singleResource.input(CommentParamsSchema).output(CommentsSchema), | ||
}, | ||
"/photos/:id": { | ||
GET: singleResource.input(PhotoParamsSchema).output(PhotoSchema), | ||
}, | ||
"/photos/:id/comments": { | ||
GET: singleResource.input(PhotoParamsSchema).output(CommentsSchema), | ||
}, | ||
"/posts/:id": { | ||
GET: singleResource.input(PostParamsSchema).output(PostSchema), | ||
}, | ||
"/posts/:id/comments": { | ||
GET: singleResource.input(PostParamsSchema).output(CommentsSchema), | ||
}, | ||
"/todos/:id": { | ||
GET: singleResource.input(TodoParamsSchema).output(TodoSchema), | ||
}, | ||
"/todos/:id/comments": { | ||
GET: singleResource.input(TodoParamsSchema).output(CommentsSchema), | ||
}, | ||
"/users/:id": { | ||
GET: singleResource.input(UserParamsSchema).output(UserSchema), | ||
}, | ||
"/users/:id/comments": { | ||
GET: singleResource.input(UserParamsSchema).output(CommentsSchema), | ||
}, | ||
}); | ||
|
||
export const jsonPlaceholderSafeRouter = | ||
allResourcesRouter.merge(singleResourceRouter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { initUntypeable } from "untypeable"; | ||
|
||
import { NewsSchema } from "./news/news.validators"; | ||
import { StockSchema, StocksParamsSchema } from "./stocks/stocks.validators"; | ||
import { | ||
WeatherSchema, | ||
WeatherParamsSchema, | ||
} from "./weather/weather.validators"; | ||
|
||
const u = initUntypeable(); | ||
|
||
export const lilSafeRouter = u.router({ | ||
"/news": u.output(NewsSchema), | ||
"/stocks": u.input(StocksParamsSchema).output(StockSchema), | ||
"/weather": u.input(WeatherParamsSchema).output(WeatherSchema), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { initUntypeable } from "untypeable"; | ||
|
||
import { InsightSchema } from "./insight/insight.validators"; | ||
import { LogSchema } from "./log/log.validators"; | ||
|
||
const u = initUntypeable(); | ||
|
||
export const logSnagSafeRouter = u.router({ | ||
"/insight": u.input(InsightSchema).output(InsightSchema), | ||
"/log": u.input(LogSchema).output(LogSchema), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.