Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative approach to previous PR. #4

Merged
merged 28 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6276f91
Merge pull request #3 from varsnothing/vn/feat/EC-002-ec-001-tenancy-…
varsnothing Jan 25, 2024
1f92f16
Merge pull request #5 from varsnothing/dev
varsnothing Jan 26, 2024
5e12dcb
Merge pull request #6 from varsnothing/encord
varsnothing Jan 26, 2024
f277e1f
ar(feat) flowtime(2:05): preparing navbar for features, add user acti…
angeloreale Jan 26, 2024
dc483be
ar(feat) starting the day with a basepath
angeloreale Jan 27, 2024
e8dadbb
ar(feat) adding insta
angeloreale Jan 27, 2024
b9540cc
ar(feat) so much to do, so little time. mui/base, HELPS. also, workin…
angeloreale Jan 27, 2024
8b0afbc
ar(feat) flowtime(freestyle) oplog+mutex+Nachus+NexusDB+etc
angeloreale Jan 27, 2024
5bd6a02
ar(debug) race-condition: logs at least more readable.
angeloreale Jan 27, 2024
5414e9c
ar(feat) I will focus better tomorrow. Part of my weekend unwind proc…
angeloreale Jan 27, 2024
83a2ef4
ar(feat) Flowing better, better logs... I need to write now, brb.
angeloreale Jan 28, 2024
9215eb7
ar(rabbit) sometimes i go deep, and I feel like there is no way back …
angeloreale Jan 29, 2024
bdc89ea
ar(feat) flow:shuffling:pickingup
angeloreale Feb 6, 2024
edb39fd
ar(feat) flow:reduce-logs
angeloreale Feb 6, 2024
a7e83ae
ar(kiss)
angeloreale Feb 6, 2024
a8e2f38
ar(kiss) then update iface
angeloreale Feb 6, 2024
c496e3e
ar(preporg)
angeloreale Feb 6, 2024
7fb7ce6
ar(schemas)
angeloreale Feb 6, 2024
798ace5
ar(enforce default org)
angeloreale Feb 6, 2024
e3bf878
ar(slow and easy)
angeloreale Feb 6, 2024
081fdda
ar(feat) flow:init:default:org
angeloreale Feb 6, 2024
e413540
ar(cleanup)
angeloreale Feb 6, 2024
2945bf7
ar(cleanup)
angeloreale Feb 6, 2024
6dff444
ar(cleanup)
angeloreale Feb 6, 2024
c1625f3
ar(cleanup)
angeloreale Feb 6, 2024
5b1dc83
ar(cleanup)
angeloreale Feb 6, 2024
b67ed82
ar(build)
angeloreale Feb 6, 2024
050fd6e
ar(lock-file)
angeloreale Feb 6, 2024
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
25 changes: 24 additions & 1 deletion .env.public
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# please copy and fill this to .env.local
# or add it to you ci environment


# ----------------
# PRIVATE VARIABLES
# @@@ WARNING: DON'T ADD NEXT_PUBLIC_* VARIABLES IF THEY'RE PRIVATE @@@

# env specific
NEXTAUTH_SECRET=
NEXTAUTH_URL=
Expand All @@ -19,6 +24,9 @@ EMAIL_FROM=
# modes: "full" (feats: enable-multi-tenancy,;)
NEXUS_MODE=

# base path: server-only
NEXUS_BASE_PATH=

# env agnostic
MONGODB_URI=

Expand All @@ -27,4 +35,19 @@ MONGODB_DATABASE=

# optional dbs (if used, all must be filled)
MONGODB_USERS_DATABASE=
MONGODB_ORGS_DATABASE=
MONGODB_ORGS_DATABASE=
MONGODB_DEFAULT_ORG=

# ----------------
# PUBLIC VARIABLES
# @@@ WARNING: THESE APPEAR IN THE BROWSER OF EVERY VISITOR @@@

# base path: client (browser)
NEXT_PUBLIC_NEXUS_BASE_PATH=
NEXT_PUBLIC_NEXUS_NAME=
NEXT_PUBLIC_NEXUS_LOGO_PATH=
NEXT_PUBLIC_NEXUS_DEFAULT_IMAGE_PATH=

# config
ENABLE_LOG=true
LOG_DEPTH=1
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# .eslintignore

.github/

# temporary
system/
components/
nsx/
7 changes: 1 addition & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"extends": [
"next/core-web-vitals",
"alloy",
"alloy/react",
"alloy/typescript"
]
"extends": ["next/core-web-vitals", "alloy", "alloy/react", "alloy/typescript"]
}
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# .prettierignore

.github/


# temporary
src/app/components/system/**/*
**/components/**/*
**/nsx/**/*
14 changes: 7 additions & 7 deletions .prettierrc.js → .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ module.exports = {
useTabs: false,
semi: true,
singleQuote: true,
quoteProps: "as-needed",
quoteProps: 'as-needed',
jsxSingleQuote: false,
trailingComma: "all",
trailingComma: 'all',
bracketSpacing: true,
bracketSameLine: false,
arrowParens: "always",
arrowParens: 'always',
rangeStart: 0,
rangeEnd: Infinity,
requirePragma: false,
insertPragma: false,
proseWrap: "preserve",
htmlWhitespaceSensitivity: "css",
proseWrap: 'preserve',
htmlWhitespaceSensitivity: 'css',
vueIndentScriptAndStyle: false,
endOfLine: "lf",
embeddedLanguageFormatting: "auto",
endOfLine: 'lf',
embeddedLanguageFormatting: 'auto',
singleAttributePerLine: false,
};
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@ License: © Purizu di Angelo Reale

Authors: varsnothing aka Angelo Reale

This repo is just an exercise on some engineering design patterns. I've used Next.js new pragma (App Router) to apply them, so that I could also learn that new way of using Next.js.

I didn't use Co-Pilot, nor ChatGPT. I use Sublime and Tmux. What is auto-suggestion and intelli-sense?

After a few weeks without coding, I have to say I should have been less eager to try so many new things/technologies/patterns in such a short timeframe, as that has definitely impacted my velocity and workflow. Also, TypeScript can slow things down when I'm out of stretch.

Nonetheless, I think I had a good opportunity to use a few of the things I like the most (DRY, YAGNI, KISS, SOLID, MVC, Singleton, Decorator, Curry, Flux, Interface, Gateway and other patterns). At the end I even thought of using Mutex for optimization on the context, but maybe next time.

I'm looking for a new job, and you can check my CV / book some time with me here: https://angeloreale.com


Why Libs?
Why Libs:

react

Expand Down
3 changes: 3 additions & 0 deletions lib/actions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// README.md

This directory stores all Server/User Initiated Actions/Operations related things
126 changes: 126 additions & 0 deletions lib/actions/actions-init.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// actions-init.tsx
/* eslint-disable react-hooks/exhaustive-deps, react-hooks/rules-of-hooks */
'use client';
import type { ISupportedContexts, IActionBack, IAction, IStatus, ICreateAction, IDispatch, IPayload } from '@types';

import { createLogMessage, fluxLog as log } from '@log';
import { useState, useEffect, useContext, useRef } from 'react';

export const CreateAction: ICreateAction =
({ action, type, verb, context }: IActionBack) =>
({ cb }: IAction) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const noop: IDispatch = async (...payload: IPayload): Promise<void> => {};

// to-do: abstract from auth context (link to ticket)
const _context: ISupportedContexts = useContext<ISupportedContexts>(context);
const { setter }: ISupportedContexts = _context;

const init = useRef(false);
const s_current = useRef('loaded');
const message = useRef('');
const to_call = useRef<IDispatch>(noop);
const status = useRef<IStatus>({
current: s_current.current,
str: createLogMessage(),
ok: undefined,
});
const payload = useRef<IPayload>();
const [dispatchd, setDispatchd] = useState(false);

const updateStatus = ({ ok }: { ok: boolean | undefined } = { ok: undefined }) => {
const _status = {
category: 'flux',
type,
action,
verb,
message: message.current,
status: s_current?.current,
};
const str = createLogMessage(_status);
status.current = {
str,
ok,
current: s_current.current,
};
log(_status);
};

const cancel = () => {
updateStatus({ ok: undefined });
return;
};

const dispatch: IDispatch = (clientPayload, toCall) => {
payload.current = { ...clientPayload };
s_current.current = 'init:active';
message.current = 'dispatched';
to_call.current = toCall || noop;
updateStatus();
setDispatchd(!dispatchd);
};

const reset = () => {
payload.current = undefined;
setDispatchd(false);
};

useEffect(() => {
if (!dispatchd) {
s_current.current = 'init:idle';
message.current = 'not dispatched yet';
return cancel();
}

if (!payload?.current) {
s_current.current = 'cancelled';
message.current = 'no payload data';
return cancel();
}

s_current.current = 'started';
message.current = 'loading payload data';
updateStatus();

if (setter) {
setter({
..._context,
...payload.current,
history: [..._context.history, status.current.str],
});
}

init.current = true;

s_current.current = 'in progress';
message.current = 'calling functions';
updateStatus({ ok: undefined });

if (typeof to_call?.current === 'function') to_call.current(payload.current);

s_current.current = 'completed';
message.current = 'success';
updateStatus({ ok: true });

if (cb && cb?.length > 0) {
cb.forEach((_cb) => {
_cb();
});
}

reset();

return () => {
s_current.current = 'ended';
message.current = 'exit 0';
updateStatus();
reset();
};
}, [dispatchd]);

return [status?.current?.ok, dispatch];
};

export const BuildAction = (Component: ICreateAction, options: IActionBack) => {
return Component(options);
};
Loading
Loading