Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/early-rockets-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@medialit/thumbnail": patch
"@medialit/images": patch
---

Eslint upgraded
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions .eslintrc.js

This file was deleted.

7 changes: 2 additions & 5 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
CI: true

jobs:
publish-packages:
lint-format-test:
runs-on: ubuntu-latest
steps:
- name: checkout
Expand Down Expand Up @@ -46,10 +46,7 @@ jobs:

- name: Build dependencies
run: |
pnpm --filter=@medialit/utils build
pnpm --filter=@medialit/models build
pnpm --filter=@medialit/images build
pnpm --filter=@medialit/thumbnail build
pnpm -r build

- name: Run test
run: pnpm test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Dependencies
node_modules
Expand Down
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions .husky/pre-commit
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
2 changes: 1 addition & 1 deletion .migrations/00000-media-by-apikey.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ db.users.find().forEach(async (user) => {
if (firstApikey) {
await db.media.updateMany(
{ userId: user._id },
{ $set: { apikey: firstApikey.key } }
{ $set: { apikey: firstApikey.key } },
);
console.log(`Updated ${user.email} media`);
}
Expand Down
2 changes: 1 addition & 1 deletion .migrations/00002-set-unique-id-to-apikeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function updateCollection() {
const doc = await cursor.next();
await collection.updateOne(
{ _id: doc._id },
{ $set: { keyId: nanoid() } }
{ $set: { keyId: nanoid() } },
);
}
} finally {
Expand Down
140 changes: 70 additions & 70 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,23 @@ produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these
conditions:

- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
- a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
- b) The work must carry prominent notices stating that it is
released under this License and any conditions added under
section 7. This requirement modifies the requirement in section 4
to "keep intact all notices".
- c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
- d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.

A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
Expand All @@ -239,42 +239,42 @@ sections 4 and 5, provided that you also convey the machine-readable
Corresponding Source under the terms of this License, in one of these
ways:

- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.
- a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
- b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the Corresponding
Source from a network server at no charge.
- c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
- d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
- e) Convey the object code using peer-to-peer transmission,
provided you inform other peers where the object code and
Corresponding Source of the work are being offered to the general
public at no charge under subsection 6d.

A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
Expand Down Expand Up @@ -350,23 +350,23 @@ Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders
of that material) supplement the terms of this License with terms:

- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.
- a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
- b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
- c) Prohibiting misrepresentation of the origin of that material,
or requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
- d) Limiting the use for publicity purposes of names of licensors
or authors of the material; or
- e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
- f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions
of it) with contractual assumptions of liability to the recipient,
for any liability that these contractual assumptions directly
impose on those licensors and authors.

All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
Expand Down
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,31 @@ Hence, we need to enable it on our own. To do that, set the following environmen
ENABLE_TRUST_PROXY=true
```

## Creating a local user
## Creating a User

In order to interact with the API, you need to have an API key. To create one, execute the following command.
In order to interact with the service, you need to have a user. You can interact with the service using the user's API key.

To create one, set up the following variable in your `.env` file:

```sh
EMAIL=email@yourdomain.com
```

When the app starts for the very first time, a user with the provided email will be generated, and their subscription will be renewed for 10 years.

Additionally, an API key will be generated for the user and printed in the application logs. The log containing the API key will look something like the following:

```sh
docker exec <container_id | container_name> node /app/apps/api/dist/src/scripts/create-local-user.js <email>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ API key: testcktI8Sa71QUgYtest @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
```

After running the above command, you will get an API key which you can use to interact with the app.
> CAUTION: Keep the generated API key confidential, as anyone could use it to store files on your instance.

You can only run this script once.
## API documentation

> CAUTION: Keep the generated API key confidential as anyone could be able to store files on your instance.
In order to interact with the service, you have to use the REST API. Our official Postman collection is available [here](https://www.postman.com/dark-rocket-625879/codelit/collection/5b8hfkr/medialit).

## Development

Expand Down
14 changes: 7 additions & 7 deletions apps/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

### Patch Changes

- Updated dependencies [0ecea51]
- @medialit/thumbnail@0.0.27
- Updated dependencies [0ecea51]
- @medialit/thumbnail@0.0.27

## 0.0.26

### Patch Changes

- Updated dependencies [bbb81e7]
- @medialit/thumbnail@0.0.26
- Updated dependencies [bbb81e7]
- @medialit/thumbnail@0.0.26

## 0.0.25

### Patch Changes

- Updated dependencies [7a07e615]
- @medialit/thumbnail@0.0.25
- @medialit/images@0.0.25
- Updated dependencies [7a07e615]
- @medialit/thumbnail@0.0.25
- @medialit/images@0.0.25
6 changes: 3 additions & 3 deletions apps/api/__tests__/apikey/handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("API key test suite", () => {
json: (data: any) => data,
}),
};
const response = await createApikey(req, res, () => {}); // eslint-disable-line @typescript-eslint/no-empty-function
const response = await createApikey(req, res, () => {});
assert.strictEqual(response.error, "Name is required");
});

Expand All @@ -36,9 +36,9 @@ describe("API key test suite", () => {
}),
};
mock.method(queries, "createApiKey").mock.mockImplementation(
async () => ({ key: "123" })
async () => ({ key: "123" }),
);
const response = await createApikey(req, res, () => {}); // eslint-disable-line @typescript-eslint/no-empty-function
const response = await createApikey(req, res, () => {});
assert.strictEqual(response.key, "123");
});
});
13 changes: 3 additions & 10 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,25 @@
"@medialit/models": "workspace:*",
"@medialit/thumbnail": "workspace:*",
"@medialit/utils": "workspace:^0.1.0",
"aws-sdk": "^2.1099.0",
"aws-sdk": "^2.1692.0",
"cors": "^2.8.5",
"dotenv": "^16.0.0",
"dotenv": "^16.4.7",
"express": "^4.18.2",
"express-fileupload": "^1.3.1",
"joi": "^17.6.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^8.0.1",
"nodemailer": "^6.7.2",
"passport": "^0.5.2",
"passport-jwt": "^4.0.0",
"passport-magic-link": "^2.1.0",
"pino": "^7.9.1",
"pug": "^3.0.2"
"pino": "^7.9.1"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.20",
"@types/express-fileupload": "^1.2.2",
"@types/jsonwebtoken": "^8.5.8",
"@types/mongoose": "^5.11.97",
"@types/node": "^20.8.7",
"@types/nodemailer": "^6.4.4",
"@types/passport": "^1.0.7",
"@types/passport-jwt": "^3.0.6",
"@types/pug": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"eslint": "^8.12.0",
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/apikey/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Apikey } from "@medialit/models";
export async function createApikey(
req: any,
res: any,
next: (...args: any[]) => void
next: (...args: any[]) => void,
) {
const { name } = req.body;
if (!name) {
Expand All @@ -28,7 +28,7 @@ export async function createApikey(
export async function getApikey(
req: any,
res: any,
next: (...args: any[]) => void
next: (...args: any[]) => void,
) {
const { keyId } = req.params;

Expand All @@ -48,7 +48,7 @@ export async function getApikey(
export async function deleteApikey(
req: any,
res: any,
next: (...args: any[]) => void
next: (...args: any[]) => void,
) {
const { keyId } = req.params;

Expand Down
Loading