Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modernize repo #131

Merged
merged 19 commits into from
Dec 22, 2023
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

4 changes: 0 additions & 4 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
21.5.0
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.editorconfig
.env
.jshintrc
.travis.yml
app.json
test
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit"
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:21-alpine

# Create app directory
WORKDIR /mockbin
Expand Down
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ other than the dependencies listed in [package.json](package.json) The following
you will need to tell *mockbin* where Redis is:

```shell
npm config set mockbin:redis redis://127.0.0.1:6379
export MOCKBIN_REDIS=redis://127.0.0.1:6379
```

By Default the server will run on port `8080`, you can customize the port like so:

```shell
npm config set mockbin:port 8001
export MOCKBIN_PORT=8001
```

*read more on [Configuration](docs/config.md)*.
Expand Down
21 changes: 0 additions & 21 deletions app.json

This file was deleted.

24 changes: 0 additions & 24 deletions bin/mockbin

This file was deleted.

12 changes: 12 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/1.4.0/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
Empty file removed docs/config.md
Empty file.
47 changes: 47 additions & 0 deletions lib/dbconfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import redis from "redis";

const client = redis.createClient(process.env.MOCKBIN_REDIS);

client.on("connect", () => {
console.log("Redis Database connected" + "\n");
});

client.on("reconnecting", () => {
console.log("Redis client reconnecting");
});

client.on("ready", () => {
console.log("Redis client is ready");
});

client.on("error", (err) => {
console.log(`Something went wrong ${err}`);
});

client.on("end", () => {
console.log("\nRedis client disconnected");
console.log("Server is going down now...");
process.exit();
});
export default client;

// const set = (key, value) => {
// client.set(key, value, redis.print);
// return "done";
// };

// const get = (key) => {
// return new Promise((resolve, reject) => {
// client.get(key, (error, result) => {
// if (error) {
// console.log(error);
// reject(error);
// }
// resolve(result);
// });
// });
// };

// const close = () => {
// client.quit();
// };