Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
supersonictw committed May 26, 2024
1 parent 51c72aa commit f8406cb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 35 deletions.
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# earendel

Tiny microservice framework with flexible.
Simple caching server for DevOps.

This is a microservice framework using Node.js + express.js,
provides the tree to write your service with a tidy and clear structure of project.
The server provides a simple API for caching data like text or binary files.

The framework is recommended to be used on light payload tasks.
## Installation

![lavateinn](logo.png)
```shell
npm install
```

## Development

Expand All @@ -25,3 +26,35 @@ Start the service for providing to our dear clients!
```shell
npm start
```

## API

### GET /token

Generate a new token. The token is a [nanoid](https://www.npmjs.com/package/nanoid).

Every token is unique, and it is used to identify the content in the cache.

### GET /text/:token

Get the text content from the cache.

### POST /text/:token

Save the text content to the cache.

### DELETE /text/:token

Delete the text content from the cache.

### GET /file/:token

Get the file content from the cache.

### POST /file/:token

Save the file content to the cache.

### DELETE /file/:token

Delete the file content from the cache.
1 change: 0 additions & 1 deletion app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const pluginPromises = [];
// Define router names
const routerNames = [
"root",
"session",
"text",
"file",
];
Expand Down
Binary file removed logo.png
Binary file not shown.
15 changes: 12 additions & 3 deletions src/routes/root.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
useApp,
} from "../init/express.mjs";

import {
nanoid,
} from "nanoid";

// Export routes mapper (function)
export default () => {
// Use application
Expand All @@ -15,14 +19,19 @@ export default () => {
// API Index Message
app.get("/", (_, res) => {
const meetMessage = `
Star Inc. Lavateinn Framework <br />
<a href="https://github.com/star-inc/lavateinn" target="_blank">
https://github.com/star-inc/lavateinn
earendel <br />
<a href="https://github.com/star-inc/earendel" target="_blank">
https://github.com/star-inc/earendel
</a>
`;
res.status(StatusCodes.IM_A_TEAPOT).send(meetMessage);
});

// Get the token
app.get("/token", (_, res) => {
res.send(nanoid());
});

// The handler for robots.txt (deny all friendly robots)
app.get("/robots.txt", (_, res) => {
res.type("txt").send("User-agent: *\nDisallow: /");
Expand Down
25 changes: 0 additions & 25 deletions src/routes/session.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion src/utils/visitor.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The simple toolbox for fetch visitor information from HTTP request.
// The simple toolbox for fetching visitor information from HTTP request.

/**
* Get IP Address.
Expand Down

0 comments on commit f8406cb

Please sign in to comment.