Skip to content

Commit

Permalink
refactor(storage): simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
becem-gharbi committed May 22, 2023
1 parent 5fb36cd commit c6ad362
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
27 changes: 11 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,17 @@ const settings: LocalSettings = {
storage: storage,
appName: process.env.APP_NAME || "default",
},
adminAuth: {
type: "credentials",
users: [
{
username: "admin",
password:
"$2b$08$1DooD4I2bJVYmxEVF69L2e55N8KkO/dn3QMFwvCtt.tgrD9X7cB/m",
permissions: "*",
},
],
},
contextStorage: {
default: {
module: "localfilesystem",
},
},
// adminAuth: {
// type: "credentials",
// users: [
// {
// username: "admin",
// password:
// "$2b$08$1DooD4I2bJVYmxEVF69L2e55N8KkO/dn3QMFwvCtt.tgrD9X7cB/m",
// permissions: "*",
// },
// ],
// },
};

const app = express();
Expand Down
4 changes: 2 additions & 2 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const storageModule: StorageModule = {
getLibraryEntry: async function (type, name) {
if (name == "") {
name = "/";
} else if (name.substr(0, 1) != "/") {
} else if (!name.startsWith("/")) {
name = "/" + name;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ export const storageModule: StorageModule = {
var p = name.split("/"); // strip multiple slash
p = p.filter(Boolean);
name = p.slice(0, p.length).join("/");
if (name != "" && name.substr(0, 1) != "/") {
if (name != "" && !name.startsWith("/")) {
name = "/" + name;
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2020",
"sourceMap": true,
"sourceMap": false,
"outDir": "dist",
"skipLibCheck": true
},
Expand Down

0 comments on commit c6ad362

Please sign in to comment.