Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 870 Bytes

README.md

File metadata and controls

39 lines (29 loc) · 870 Bytes

git-express

Simple library providing middleware for express server to easy build git server

Install

$ npm i git-express

Example

import gitMiddleware, { AuthorizationCredentials, GitMiddlewareAuthorizationMode } from "git-express";

const app = express();
const port = 3000;

app.use(gitMiddleware({
	repositoryResolver: (repositoryPath: string) => {
		return {
			authorizationMode: GitMiddlewareAuthorizationMode.PUSH_ONLY,
			gitRepositoryDirectory: "/path/to/repos/base/" + repositoryPath
		}
	},
	authorize: (repositoryPath: string, credentials: AuthorizationCredentials) => {
		return credentials.username === "admin" && credentials.password === "admin";
	}
}));

app.get('/', (req, res) => {
	res.send('Hello World!')
});

app.listen(port, () => {
	console.log(`Example app listening at http://localhost:${port}`)
});