Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@ethicdevs/fastify-git-server
Advanced tools
Readme
fastify-git-server
A Fastify plugin to easily make one/many Git repositories available for clone/fetch/push.
$ yarn add @ethicdevs/fastify-git-server
# or
$ npm i @ethicdevs/fastify-git-server
// server.ts
// std
import { resolve } from "node:path";
// 3rd-party
import fastify from "fastify";
// app
import fastifyGitServer, { GitServer } from "@ethicdevs/fastify-git-server";
const HOST = process.env.HOST || "localhost";
const PORT = process.env.PORT != null ? parseInt(process.env.PORT, 10) : 4200;
async function main() {
const server = fastify();
server.register(fastifyGitServer, {
// can be set to a path to git, else will directly call "git" from $PATH.
gitExecutablePath: undefined,
// a method to authorise the fact that the user can fetch/push, or not.
async authorize(repoSlug, credentials) {
if (repoSlug.toLowerCase() === "testorg/test-repo") {
return (
credentials.username === "test" && credentials.password === "test"
);
}
return false;
},
// a method to resolve the repository directory on disk and its authorisation mode.
async repositoryResolver(repoSlug) {
if (repoSlug !== "testorg/test-repo") {
throw new Error("Cannot find such repository.");
}
return {
authMode: GitServer.AuthMode.ALWAYS, // or PUSH_ONLY, or NEVER.
gitRepositoryDir: resolve(
"/home/git-server-user/repos/testorg/test-repo",
),
};
},
});
server.listen(PORT, HOST, (err, listeningOnUrl) => {
if (err != null) {
console.error(`❌ Could not start server. Error: ${err.message}`);
} else {
console.log(`🚀 Server is up and running at: ${listeningOnUrl}`);
}
});
return server;
}
main();
Run the server like so (or build/bundle it first), and enjoy!
$ ts-node server.ts
# Server is up and running at http://localhost:4200
Now you can easily git clone/fetch/push to the repository assuming you pass the right credentials set for the right repository.
$ git clone http://localhost:4200/testorg/test-repo.git
$ cd test-repo/
$ git fetch
$ git pull --rebase
$ echo "Today is: $(date)" >> ReadMe.md
$ git commit -am 'docs(readme): add the date of today'
$ git push
Contributions to this repository are welcome to everyone, please feel free to send a pull request for further review/discussion/merging/resolution. 👌
$ yarn test # run all tests
$ yarn test --coverage # get coverage in ./coverage/lcov-report/index.html
$ yarn test --coverage --watchAll # (dev) quick test iteration loop
$ yarn build
$ yarn typecheck # same but does not write to ./dist folder (only check types)
This library is a port of git-express, aimed at Fastify v3.x+. Original lib' has not received any update for more than 2 years now and has been released without any license...
It was a great source of inspiration for this library to be born, so thanks to the author for that piece of code! 😅
The MIT license.
FAQs
A Fastify plugin to easily make one/many Git repositories available for clone/fetch/push.
The npm package @ethicdevs/fastify-git-server receives a total of 1 weekly downloads. As such, @ethicdevs/fastify-git-server popularity was classified as not popular.
We found that @ethicdevs/fastify-git-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.