Skip to content

Commit

Permalink
init app
Browse files Browse the repository at this point in the history
  • Loading branch information
roverflow committed Nov 2, 2024
1 parent 97e23fa commit ad19f56
Show file tree
Hide file tree
Showing 25 changed files with 12,542 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SCHOOL_VALUE=tvsdriftrpune
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules

/.cache
/build
.env
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.tabSize": 2,
"files.autoSave": "onFocusChange",
"eslint.options": { "configFile": "eslint.config.js" }
}
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
# ora-school
# Welcome to Remix!

- 📖 [Remix docs](https://remix.run/docs)

## Development

Run the dev server:

```shellscript
npm run dev
```

## Deployment

First, build your app for production:

```sh
npm run build
```

Then run the app in production mode:

```sh
npm start
```

Now you'll need to pick a host to deploy it to.

### DIY

If you're familiar with deploying Node applications, the built-in Remix app server is production-ready.

Make sure to deploy the output of `npm run build`

- `build/server`
- `build/client`

## Styling

This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever css framework you prefer. See the [Vite docs on css](https://vitejs.dev/guide/features.html#css) for more information.
1 change: 1 addition & 0 deletions app/components/navigation/footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//footer
1 change: 1 addition & 0 deletions app/components/navigation/navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Navbar
1 change: 1 addition & 0 deletions app/config/school-constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const SCHOOLDATA = {};
18 changes: 18 additions & 0 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
);
});
140 changes: 140 additions & 0 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.server
*/

import { PassThrough } from "node:stream";

import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToPipeableStream } from "react-dom/server";

const ABORT_DELAY = 5_000;

export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
// This is ignored so we can keep it in the template for visibility. Feel
// free to delete this parameter in your app if you're not using it!
// eslint-disable-next-line @typescript-eslint/no-unused-vars
loadContext: AppLoadContext
) {
return isbot(request.headers.get("user-agent") || "")
? handleBotRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
)
: handleBrowserRequest(
request,
responseStatusCode,
responseHeaders,
remixContext
);
}

function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onAllReady() {
shellRendered = true;
const body = new PassThrough();
const stream = createReadableStreamFromReadable(body);

responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
})
);

pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
}
);

setTimeout(abort, ABORT_DELAY);
});
}

function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
return new Promise((resolve, reject) => {
let shellRendered = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onShellReady() {
shellRendered = true;
const body = new PassThrough();
const stream = createReadableStreamFromReadable(body);

responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(stream, {
headers: responseHeaders,
status: responseStatusCode,
})
);

pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
// Log streaming rendering errors from inside the shell. Don't log
// errors encountered during initial shell rendering since they'll
// reject and get logged in handleDocumentRequest.
if (shellRendered) {
console.error(error);
}
},
}
);

setTimeout(abort, ABORT_DELAY);
});
}
51 changes: 51 additions & 0 deletions app/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react";
import type { LinksFunction } from "@remix-run/node";

import "./tailwind.css";

export const links: LinksFunction = () => [
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
{
rel: "preconnect",
href: "https://fonts.gstatic.com",
crossOrigin: "anonymous",
},
{
rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
},
];

export function Layout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
</head>
<body>
{children}
<ScrollRestoration />
<Scripts />
</body>
</html>
);
}

export default function App() {
return (
<>
navbar
<Outlet />
footer
</>
);
}
17 changes: 17 additions & 0 deletions app/routes/$courseName.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { LoaderFunctionArgs } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";

import { getCourseInfo } from "~/services/school-service";

export const loader = async ({
params,
}: LoaderFunctionArgs): Promise<string> => {
const courseName = params.courseName ?? "defaultCourseName";
const courseInfo = getCourseInfo(courseName);
return courseInfo;
};

export default function courseName() {
const courseInfo = useLoaderData<any>();
return <section>{courseInfo}</section>;
}
23 changes: 23 additions & 0 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { MetaFunction, LoaderFunctionArgs } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { getLocationInfo } from "~/services/school-service";

export const meta: MetaFunction = () => {
return [
{ title: "School Name" },
{ name: "description", content: "Welcome to school" },
];
};

export const loader = async ({
params,
}: LoaderFunctionArgs): Promise<string> => {
const schoolName = process.env.SCHOOL_VALUE ?? "defaultSchoolName";
const locationInfo = getLocationInfo(schoolName);
return locationInfo;
};

export default function Index() {
const locationInfo = useLoaderData<any>();
return <section>{locationInfo}</section>;
}
7 changes: 7 additions & 0 deletions app/services/school-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function getLocationInfo(school_value: string) {
return `School name is ${school_value}`;
}

export function getCourseInfo(courseName: string) {
return `Course name is ${courseName}`;
}
7 changes: 7 additions & 0 deletions app/tailwind.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

html,
body {
}
1 change: 1 addition & 0 deletions app/utils/text_formatting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// text formatting functions
31 changes: 31 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import pluginReact from "eslint-plugin-react";

export default [
{ files: ["**/*.{ts,tsx}"] },
{ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
{ languageOptions: { globals: globals.browser } },
{
settings: {
react: {
version: "18.3",
},
},
},
pluginJs.configs.recommended,
pluginReact.configs.flat.recommended,
{
rules: {
// suppress errors for missing 'import React' in files
"react/react-in-jsx-scope": "off",
"no-console": "error",
"react/prop-types": "off",
// allow jsx syntax in js files (for next.js project)
"react/jsx-filename-extension": [
1,
{ extensions: [".ts", ".tsx", ".js", ".jsx"] },
], //should add ".ts" if typescript project
},
},
];
Loading

0 comments on commit ad19f56

Please sign in to comment.