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
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,51 @@ jobs:
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
# with:
# # Automatically inject basePath in your Next.js configuration file and disable
# # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
# #
# # You may remove this line if you want to manage the configuration yourself.
# static_site_generator: next
# generator_config_file: apps/docs/next.config.js
- name: Dump Pages configuration
run: |
echo PAGES_BASE_URL: ${{ steps.pages.outputs.base_url }}
echo PAGES_ORIGIN: ${{ steps.pages.outputs.origin }}
echo PAGES_HOST: ${{ steps.pages.outputs.host }}
echo PAGES_BASE_PATH: ${{ steps.pages.outputs.base_path }}
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
apps/docs/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
run: pnpm i
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
run: pnpm --filter @medialit/docs build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
path: ./apps/docs/out

# Deployment job
deploy:
Expand Down
2 changes: 2 additions & 0 deletions .migrations/00004-drop-internal-apikey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
db.apikeys.deleteMany({ name: "internal-apikey", internal: true });
db.apikeys.updateMany({}, { $unset: { internal: "" } });
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
**/.next
**/.next
apps/docs/.source
9 changes: 0 additions & 9 deletions apps/api/src/apikey/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ export default async function apikey(
return res.status(401).json({ error: UNAUTHORISED });
}

if (req.body.internalKey) {
const internalApikey: Apikey | null = await getApiKeyUsingKeyId(
req.body.internalKey,
);
if (!internalApikey) {
return res.status(401).json({ error: UNAUTHORISED });
}
}

// const isSubscriptionValid = await validateSubscription(
// apiKey!.userId.toString(),
// );
Expand Down
8 changes: 1 addition & 7 deletions apps/api/src/apikey/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { getUniqueId } from "@medialit/utils";
export async function createApiKey(
userId: string,
name: string,
internal?: boolean,
): Promise<Apikey> {
return await ApikeyModel.create({
name,
key: getUniqueId(),
userId,
internal: internal || false,
});
}

Expand All @@ -38,15 +36,11 @@ export async function getApiKeyByUserId(
{
key: keyId,
userId,
internal: false,
},
projections,
);
} else {
result = await ApikeyModel.find(
{ userId, internal: false },
projections,
);
result = await ApikeyModel.find({ userId }, projections);
}

return result;
Expand Down
10 changes: 1 addition & 9 deletions apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,11 @@ async function createAdminUser() {
const user: User | null = await findByEmail(email);

if (!user) {
const user = await createUser(
email,
undefined,
// new Date(
// new Date().setFullYear(new Date().getFullYear() + 100),
// ),
"subscribed",
);
const user = await createUser(email, undefined, "subscribed");
const apikey: Apikey = await createApiKey(user.id, "App 1");
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
console.log(`@ API key: ${apikey.key} @`);
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
await createApiKey(user.id, Constants.internalApikeyName, true);
}
} catch (error) {
logger.error({ error }, "Failed to create admin user");
Expand Down
28 changes: 28 additions & 0 deletions apps/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# deps
/node_modules

# generated content
.contentlayer
.content-collections
.source

# test & build
/coverage
/.next/
/out/
/build
*.tsbuildinfo

# misc
.DS_Store
*.pem
/.pnp
.pnp.js
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# others
.env*.local
.vercel
next-env.d.ts
26 changes: 26 additions & 0 deletions apps/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# docs

This is a Next.js application generated with
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).

Run development server:

```bash
npm run dev
# or
pnpm dev
# or
yarn dev
```

Open http://localhost:3000 with your browser to see the result.

## Learn More

To learn more about Next.js and Fumadocs, take a look at the following
resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs
7 changes: 7 additions & 0 deletions apps/docs/app/(home).not-used/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ReactNode } from "react";
import { HomeLayout } from "fumadocs-ui/layouts/home";
import { baseOptions } from "@/app/layout.config";

export default function Layout({ children }: { children: ReactNode }) {
return <HomeLayout {...baseOptions}>{children}</HomeLayout>;
}
19 changes: 19 additions & 0 deletions apps/docs/app/(home).not-used/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Link from "next/link";

export default function HomePage() {
return (
<main className="flex flex-1 flex-col justify-center text-center">
<h1 className="mb-4 text-2xl font-bold">Hello World</h1>
<p className="text-fd-muted-foreground">
You can open{" "}
<Link
href="/docs"
className="text-fd-foreground font-semibold underline"
>
/docs
</Link>{" "}
and see the documentation.
</p>
</main>
);
}
52 changes: 52 additions & 0 deletions apps/docs/app/(home)/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { source } from "@/lib/source";
import {
DocsPage,
DocsBody,
DocsDescription,
DocsTitle,
} from "fumadocs-ui/page";
import { notFound } from "next/navigation";
import { createRelativeLink } from "fumadocs-ui/mdx";
import { getMDXComponents } from "@/mdx-components";

export default async function Page(props: {
params: Promise<{ slug?: string[] }>;
}) {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();

const MDXContent = page.data.body;

return (
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsBody>
<MDXContent
components={getMDXComponents({
// this allows you to link to other pages with relative file paths
a: createRelativeLink(source, page),
})}
/>
</DocsBody>
</DocsPage>
);
}

export async function generateStaticParams() {
return source.generateParams();
}

export async function generateMetadata(props: {
params: Promise<{ slug?: string[] }>;
}) {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();

return {
title: page.data.title,
description: page.data.description,
};
}
12 changes: 12 additions & 0 deletions apps/docs/app/(home)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DocsLayout } from "fumadocs-ui/layouts/docs";
import type { ReactNode } from "react";
import { baseOptions } from "@/app/layout.config";
import { source } from "@/lib/source";

export default function Layout({ children }: { children: ReactNode }) {
return (
<DocsLayout tree={source.pageTree} {...baseOptions}>
{children}
</DocsLayout>
);
}
4 changes: 4 additions & 0 deletions apps/docs/app/api/search/route.ts.notused
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { source } from "@/lib/source";
import { createFromSource } from "fumadocs-core/search/server";

export const { GET } = createFromSource(source);
3 changes: 3 additions & 0 deletions apps/docs/app/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "tailwindcss";
@import "fumadocs-ui/css/neutral.css";
@import "fumadocs-ui/css/preset.css";
1 change: 1 addition & 0 deletions apps/docs/app/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions apps/docs/app/layout.config.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
import Image from "next/image";

/**
* Shared layout configurations
*
* you can customise layouts individually from:
* Home Layout: app/(home)/layout.tsx
* Docs Layout: app/docs/layout.tsx
*/
export const baseOptions: BaseLayoutProps = {
nav: {
title: (
<>
{/* <svg
width="24"
height="24"
xmlns="http://www.w3.org/2000/svg"
aria-label="Logo"
>
<circle cx={12} cy={12} r={12} fill="currentColor" />
</svg> */}
<Image src="./icon.svg" alt="Logo" width={24} height={24} />
MediaLit Docs
</>
),
},
links: [
// {
// text: "Documentation",
// url: "/",
// active: "nested-url",
// },
],
githubUrl: "https://github.com/codelitdev/medialit",
};
24 changes: 24 additions & 0 deletions apps/docs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import "./global.css";
import { RootProvider } from "fumadocs-ui/provider";
import { Inter } from "next/font/google";
import type { ReactNode } from "react";

const inter = Inter({
subsets: ["latin"],
});

export default function Layout({ children }: { children: ReactNode }) {
return (
<html lang="en" className={inter.className} suppressHydrationWarning>
<body className="flex flex-col min-h-screen">
<RootProvider
search={{
enabled: false,
}}
>
{children}
</RootProvider>
</body>
</html>
);
}
6 changes: 6 additions & 0 deletions apps/docs/content/docs/express-js.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Express
description: Integrate MediaLit with Express
---

Coming soon
Loading