-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sharing permissions and custom configuration
- Loading branch information
Showing
56 changed files
with
2,162 additions
and
1,822 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
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
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 |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import Joi from 'joi'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import { createRouter } from 'next-connect'; | ||
import Joi from 'joi'; | ||
|
||
import validate from 'lib/middlewares/validation'; | ||
// import { clone, cleanup, getProgramName } from 'lib/services/git'; for future use | ||
import { clone, getProgramName } from 'lib/services/git'; | ||
import { compress, programPublish } from 'lib/services/deploy'; | ||
import { clone, getProgramName } from 'lib/services/git'; | ||
|
||
const router = createRouter<NextApiRequest, NextApiResponse>(); | ||
|
||
const postSchema = Joi.object({ | ||
// eslint-disable-next-line no-useless-escape | ||
repository: Joi.string().pattern(/((git|http(s)?)|(git@[\w\.]+))(:(\/\/)?)([\w\.@\:\/\-~]+)(\.git)(\/)?/), | ||
entrypoint: Joi.string(), | ||
}); | ||
|
||
router.post(validate({ body: postSchema }), async (req, res) => { | ||
const { repository } = req.body; | ||
const { repository, entrypoint } = req.body; | ||
let itemHash = ''; | ||
await clone(repository).then(async (path: string) => { | ||
const fileName: string = await compress(path); | ||
itemHash = await programPublish(fileName); | ||
itemHash = await programPublish(fileName, entrypoint); | ||
// await cleanup(GITCLONE_DIR); | ||
}); | ||
return res.status(200).json({ name: getProgramName(repository), item_hash: itemHash }); | ||
return res.status(200).json({ name: getProgramName(repository), item_hash: itemHash, entrypoint }); | ||
}); | ||
|
||
export default router.handler(); |
Oops, something went wrong.