File tree Expand file tree Collapse file tree 6 files changed +12
-67
lines changed
Expand file tree Collapse file tree 6 files changed +12
-67
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ ENABLE_TRUST_PROXY=true
5151In order to interact with the API, you need to have an API key. To create one, execute the following command.
5252
5353``` sh
54- docker exec < container_id | container_name> node /app/apps/api/dist/scripts/create-local-user.js < email>
54+ docker exec < container_id | container_name> node /app/apps/api/dist/src/ scripts/create-local-user.js < email>
5555```
5656
5757After running the above command, you will get an API key which you can use to interact with the app.
Original file line number Diff line number Diff line change 22 "name" : " @medialit/api" ,
33 "version" : " 0.0.27" ,
44 "private" : true ,
5- "description" : " The service for managing uploads, users and tying everthing together " ,
5+ "description" : " A better API to manage your files on AWS S3 compatible cloud storages " ,
66 "author" : {
77 "name" : " The CodeLit Team" ,
8- "email" : " hi@rajatsaxena .dev"
8+ "email" : " hi@codelit .dev"
99 },
10- "homepage" : " https://github.com/codelitdev/cloud-upload-service #readme" ,
10+ "homepage" : " https://github.com/codelitdev/medialit #readme" ,
1111 "license" : " AGPL-3.0-or-later" ,
12- "main" : " dist/index.js" ,
12+ "main" : " dist/src/ index.js" ,
1313 "directories" : {
1414 "lib" : " lib" ,
1515 "test" : " __tests__"
1919 ],
2020 "repository" : {
2121 "type" : " git" ,
22- "url" : " git+https://github.com/codelitdev/cloud-upload-service .git"
22+ "url" : " git+https://github.com/codelitdev/medialit .git"
2323 },
2424 "bugs" : {
25- "url" : " https://github.com/codelitdev/cloud-upload-service /issues"
25+ "url" : " https://github.com/codelitdev/medialit /issues"
2626 },
2727 "scripts" : {
2828 "build" : " tsc" ,
Original file line number Diff line number Diff line change 1- import Plan from "../plan/model" ;
21import User from "../user/model" ;
3- import Subscription from "../subscription/model" ;
42import connectToDatabase , { disconnect } from "../config/db" ;
53import { createApiKey } from "../apikey/queries" ;
64import { Apikey } from "@medialit/models" ;
@@ -17,24 +15,12 @@ if (!email) {
1715 try {
1816 await connectToDatabase ( ) ;
1917
20- // Create a plan
21- const plan = await Plan . create ( {
22- maxFileSize : 10240 ,
23- maxStorage : 1024000 ,
24- } ) ;
25-
2618 // Create a user
2719 const user = await User . create ( {
2820 email,
2921 active : true ,
3022 name : "Admin" ,
31- } ) ;
32-
33- // Create a subscription
34- await Subscription . create ( {
35- userId : user . id ,
36- planId : plan . id ,
37- endsAt : new Date (
23+ subscriptionEndsAfter : new Date (
3824 new Date ( ) . setFullYear ( new Date ( ) . getFullYear ( ) + 100 )
3925 ) ,
4026 } ) ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import { getPlan } from "../plan/queries" ;
2- import { Subscription } from "./model" ;
3- import { getSubscription } from "./queries" ;
1+ import { getUser } from "../user/queries" ;
42
53export async function validateSubscription ( userId : string ) {
6- const subscription : Subscription | null = await getSubscription ( userId ) ;
7- const validSubscription =
8- subscription && isSubscriptionValid ( subscription . endsAt ) ;
9- if ( ! validSubscription ) {
10- return false ;
11- }
12-
13- const plan = await getPlan ( subscription ! . planId . toString ( ) ) ;
14- if ( ! plan ) {
15- return false ;
16- }
17-
18- return true ;
4+ const user = await getUser ( userId ) ;
5+ return user && isDateInFuture ( user . subscriptionEndsAfter ) ;
196}
207
21- function isSubscriptionValid ( dateStr : Date ) : boolean {
8+ function isDateInFuture ( dateStr : Date ) : boolean {
229 return new Date ( dateStr ) . getTime ( ) > new Date ( ) . getTime ( ) ;
2310}
You can’t perform that action at this time.
0 commit comments