- JavaScript 87.7%
- EJS 12.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| commands | ||
| lib | ||
| messageHandlers | ||
| migrations | ||
| routes | ||
| scripts | ||
| templates | ||
| tests | ||
| web | ||
| .env.example | ||
| .gitignore | ||
| commands.js | ||
| index.js | ||
| log.js | ||
| migrations.js | ||
| package-lock.json | ||
| package.json | ||
| parcelexampledata.json | ||
| README.md | ||
MyHub
MyHub is a self-hosted Discord bot and web application for managing product hubs. It includes a responsive Roblox storefront, a customer download portal, an admin portal for managing products, and account linking between Discord and Roblox.
Requirements
- Node.js 18 or newer
- MariaDB
- A Discord application and bot
Setup
-
Install dependencies:
npm install -
Create a
.envfile using.env.exampleas a template. Set the database connection details and Discord bot token at minimum. -
Create the configured MariaDB database and user, and grant the user access to that database, including permission to create and alter tables. On startup, MyHub applies pending migrations automatically. If a migration fails, startup stops rather than serving an incomplete schema. To apply migrations without starting the bot/web server, run
npm run migrateusing the same environment as the application. A failure logs the migration filename and database error and exits with a nonzero status. -
Invite the bot to your Discord server with the permissions and application-command access it needs.
-
Start the application:
npm start
The web server listens on port 3000 by default. Set SERVER_PORT to use another port.
Configuration
| Variable | Purpose |
|---|---|
DB_HOST |
MariaDB host |
DB_PORT |
MariaDB port; defaults to 3306 |
DB_USER |
MariaDB username |
DB_PASS |
MariaDB password |
DB_NAME |
MariaDB database name |
DISCORD_TOKEN |
Discord bot token |
SESSION_SECRET |
Secret used to sign web sessions; set a stable, private value |
SERVER_PORT |
Web server port; defaults to 3000 |
BASE_URL |
Public base URL, used to create portal links and OAuth redirect URLs |
BRAND_NAME |
Optional shared website brand shown in page titles, headers, footers, and legal text; defaults to MyHub |
NODE_ENV |
Set to production to enable production-specific behavior |
DISCORD_CLIENT_ID |
Optional Discord OAuth client ID; defaults to the bot application ID |
DISCORD_CLIENT_SECRET |
Optional Discord OAuth client secret |
ROBLOX_CLIENT_ID |
Optional Roblox OAuth client ID |
ROBLOX_CLIENT_SECRET |
Optional Roblox OAuth client secret |
MAX_UPLOAD_MB |
Maximum admin product upload size in MB; defaults to 500 |
For OAuth login, configure the provider credentials and register these callback URLs with the provider:
${BASE_URL}/portal/auth/discord/callback${BASE_URL}/portal/auth/roblox/callback
Keep .env and all credentials private. Use HTTPS when exposing the web application publicly.
The policy pages describe the application's built-in data handling. The operator of each deployment is responsible for adding their legal identity and contact channel and for adjusting the pages to match their deployment, retention settings, and applicable law.
Using the application
-
The root URL (
/) redirects to the customer portal (/portal). -
The privacy policy (
/privacy) and terms of service (/terms) are public pages branded withBRAND_NAME. -
All portal, admin, and legal pages use the shared EJS layout in
web/page.ejs, with commonweb/header.ejsandweb/footer.ejspartials. Page-specific templates live inweb/portal,web/admin, andweb/legal; templates escape dynamic values and are cached until the application restarts.BRAND_NAMEdoes not replace individual hub names or the exported Roblox template's filename. -
Users can sign in to the portal with configured Discord or Roblox OAuth and download products they own.
-
In Discord, use
/setupto create a hub for the server. -
Use
/link <pairing-code>to connect your account./unlinkremoves your own link; purchases stay with the Roblox account. Refresh the hub afterward to obtain a new pairing code. -
Gifts bought in the hub can go to Roblox users who have never used the hub; an empty account is created for the recipient, who can link it afterward. Admins can
/give(or use the admin portal) to an unknown Roblox ID the same way, or to a Discord user without a linked account — that grant is stored as pending and delivered automatically when the user links. Linking is always required to retrieve products. -
Authorized server administrators can use
/forcelinkwith both IDs or/forceunlinkwith a Roblox ID, Discord user, or both. Unlinking clears saved Discord identity and pairing codes without deleting ownership. Account links are shared across hubs, so these changes apply globally. -
Hub administrators can use
/adminin Discord to generate a one-time link to the admin portal. -
Set welcome and navbar image asset IDs in the admin portal's Settings, then use Download hub or
/genhubin Discord to downloadMyHub.rbxlx. Empty welcome/navbar logo fields use a monogram of the hub name, not a third-party logo. -
Open the generated
.rbxlxas a place in Roblox Studio, rather than inserting it as a model. It includes the current secret key, hub name, descriptions, terms, music, logos, and backend URL fromBASE_URL. Publish it and enable Studio API access for persistent checkout records before accepting payments. HTTP requests are enabled in the template. Keep the place private and regenerate it after changing branding or the secret key. -
To generate an admin link from the host instead, run:
npm run admin-token -- <hubId-or-discordGuildId> -
The
/healthendpoint reports web server, Discord client, and MariaDB status.
Audit logs
The admin portal has two hub-scoped views: API audit (/admin/audit) and Hub activity (/admin/activity). The API audit records calls to the API, CDN and health endpoints, including unsuccessful, malformed, unmatched and interrupted requests. It stores the UTC request time, method, normalized endpoint, response status (or aborted), duration, request IP address and recognized product, Roblox user and recipient IDs where available. It also records the Roblox-Id place ID header, or Roblox-Place-Id if the former is absent or invalid. These headers and other request IDs are client-supplied and must not be used as proof of origin. Raw query strings, request and response bodies, authorization headers and download tokens are not stored.
API requests are associated with a hub only when a valid hub key, known public product, or valid CDN download authorization identifies one. Unassociated requests (including invalid keys and unknown products) remain in the database but are not displayed to any hub admin. The activity view records successful product creation, updates, deletion, grants, revocations, purchases, gifts and free claims; hub settings and payout-share changes; account linking actions made in a hub's Discord server or admin portal; and completed product downloads from the portal or CDN, with available Roblox and Discord user IDs. Account linking in Discord DMs has no originating hub and is not shown in a hub's activity. Existing Discord hub notifications are unchanged; audit records themselves are not sent to the log channel.
The server trusts one reverse proxy hop when determining the IP address. Deploy behind a trusted proxy that overwrites forwarded-address headers and restrict direct access to the application, otherwise the recorded IP can be spoofed. Audit writes occur after API responses or successful actions; database failures are logged to the application log and may leave gaps. Logs are retained indefinitely, including records for deleted hubs and unassociated calls, so operators should apply database retention and access controls appropriate for IP addresses and account identifiers. The audit trail starts when this version is deployed; earlier activity is not backfilled.
Free products
Choose Free in a product's admin pricing field, or use /update with the Free product field and reply true. Paid is the default. Free items do not need a developer product ID; switching back to paid requires one.
The store API exposes isFree from the saved product record. The Roblox server claims an item using POST /payments/external/hub/order/claim with its private hub-secret-key header and { "robloxID": "...", "productID": "..." }. The backend checks hub membership, the saved free flag, the linked account, ownership, and stock inside a transaction. Claims are idempotent and grant the same download/library ownership as paid purchases. A client-supplied zero price or free flag never authorizes a claim.
Sales and developer payouts
Every completed purchase, gift, and free claim is recorded in the sales table with its time, buyer/recipient, and Robux spent. Generated hubs send each Roblox receipt's CurrencySpent and PurchaseId, so each receipt is counted once, even when the buyer already owns the product. Hubs generated before this feature do not send the price: their sales count as R$ 0 and the admin portal warns about them, so regenerate and republish those places. Sales are kept after a product is deleted. Purchases made before this feature have no timestamp and are not backfilled.
- Sales (
/admin/sales): per-product totals and the latest sales for an inclusive UTC date range (defaults to last month), with a CSV export. - Payouts (
/admin/payouts): assign developers (by Roblox user ID) a percentage of individual products or of all products. A product's shares cannot exceed 100% in total. For a period, each developer earns their percentage of each product's paid sales, rounded down to whole Robux per developer. Free claims never pay out. Payouts are calculated from either the estimated earned Robux (70% after Roblox's fee, the default) or the gross Robux spent. - The payout list uses Roblox's one-time group payout CSV format (
userId,payoutInRobux) and can be copied or downloaded. Roblox accepts up to 20 recipients per upload, so longer lists are split into numbered batches. Recipients must be eligible members of the paying group.
Public license checks
Call GET /hub/checkLicense/{userId}/{productId} without authentication. userId is a positive Roblox user ID (not a Discord ID); productId is the product's UUID, not its Roblox developer product ID.
For an existing product, the response is { "status": 200, "message": "OK", "data": { "hasLicense": true } }, or hasLicense: false if the user has no ownership record. Paid purchases, gifts, free claims, and admin grants all count; account linking and current stock do not affect existing ownership. Unknown users return false. Invalid IDs return HTTP 400, unknown products return 404, and database failures return 500 rather than a license decision. Responses are not cached so revocations take effect on the next check.
This endpoint intentionally makes product ownership publicly queryable. It exposes no account details or download access and does not replace authentication on protected endpoints.
Public product version checks
Set Version when creating or editing a product in the admin portal, or use /update with the Version field in Discord (~none clears it). Versions are optional text up to 64 characters, such as 1.2.3 or 2.0.0-beta.1. Existing products start with no version; replacing a file does not automatically change it.
Call GET /hub/getVersion/{productId} without authentication, using the product UUID shown in the admin editor (not its Roblox developer product ID). The editor also links to this endpoint.
{ "status": 200, "message": "OK", "data": { "version": "1.2.3" } }
Append /text (GET /hub/getVersion/{productId}/text) for a text/plain response containing only the version, such as 1.2.3, with no quotes or trailing newline. An unset version returns an empty body instead of the JSON endpoint's version: null. Both endpoints use the same validation and return JSON errors: invalid UUIDs return HTTP 400, unknown or deleted products return 404, and database failures return 500. Responses are not cached. Only the version is exposed: no secrets, account details, or download access. Clients compare it to their installed version using their own versioning scheme; string inequality signals a different release, not necessarily a newer one.
Example in a Roblox server Script with HTTP requests enabled (replace the URL and UUID):
local HttpService = game:GetService("HttpService")
local installedVersion = "1.0.0"
local ok, result = pcall(function()
return HttpService:JSONDecode(HttpService:GetAsync(
"https://your-hub.example/hub/getVersion/PRODUCT_UUID", true))
end)
if not ok then
warn("Could not check product version:", result)
elseif result.data.version and result.data.version ~= installedVersion then
warn("A different product release is available:", result.data.version)
end
Anonymous usage tracking
/admin/usage lists every product's total uses, how many places use it, and when it was last used. Open a product to see each place ID with its first and last use, and copy its Lua snippet. Put the snippet in a server Script (HTTP requests must be enabled) in the place that uses the product. On each live server start it sends POST /usage/ping with { "productId": "...", "placeId": "..." }. The API audit also records the request IP and any Roblox place ID header. Studio sessions and unpublished places are skipped.
Pings need no secret and store only the product ID, place ID, a use count, and first/last-seen times; no player, IP, or job data is stored. Unknown products are rejected. Each product/place pair is limited to 60 pings per minute per backend process.
Product ratings
Linked players who own a product can rate it from 1 to 5 stars in its details dialog in the Roblox store, and can change their rating at any time. The store server calls POST /hub/rate with its secret key and { "robloxID", "productID", "score" }. The backend checks the hub, the linked account, and ownership. /hub/getSession returns each product's rating (currentScore, maxScore, amountOfReviews) and the player's own playerData.myRating. Ratings are deleted with their product.
Studio storefront template
The MyHub storefront is built directly in the connected Place1 Studio instance. Its editable preview is in StarterGui.HubStoreGui, its responsive builder and public branding are in ReplicatedStorage.HubStore, and its server adapter/private settings are in ServerScriptService. The generated-place template captures these original scripts, remotes, and configuration modules; the GUI is built at runtime. It is a standalone storefront place, not a copy of the Studio world's geometry or the former Parcel model. ServerStorage.TemplateInstructions describes its contract.
Substitute {{hub_name}}, {{short_description}}, {{long_description}}, {{tos}}, {{welcome_logo}}, {{navbar_logo}}, {{group_logo}}, and {{music_id}} in public branding. Substitute {{secret_key}} and {{base_url}} only in the private settings module. Use Roblox image URLs for logos, and escape substituted Lua strings and XML/CDATA correctly. Never move private settings to replicated storage.
The generator fills these from the saved hub settings. The optional group logo override defaults to empty; it can be set directly in the public Branding module in Studio. Otherwise the server resolves the published place's creator: group-owned places use the group icon, user-owned places use the owner's avatar. This identity is available before account linking and in Studio previews with creator metadata. Local unpublished files have no creator ID: publish under the intended group or set Branding.GroupLogo explicitly. The sidebar's main brand mark uses the custom navbar logo first, then a group logo override, then the creator icon, with a monogram only when no image is available. The hub name remains the main title; the actual creator/group name appears directly below it instead of the generic marketplace subtitle. Names wrap within bounded labels and truncate rather than overlapping navigation. The same image appears on About (including mobile), independent of screen height. MyHub is the platform/preview name; generated storefronts continue to use each hub's own name.
Successful linked sessions hide the connection banner. Account-unavailable notices, refresh progress, errors, and the Studio preview notice remain visible. Roblox UI copy does not advertise Discord, websites, or external downloads. Account linking still displays /link <code> with an instruction to run the command and refresh, without saying where to run it. Account identity uses the Roblox username, and the backend URL remains server-only. Existing backend account eligibility requirements still apply; unavailable accounts cannot purchase. Hub owners must keep custom names, descriptions, terms, and images appropriate for Roblox; user-supplied branding is not automatically rewritten.
Store access is locked until a successful session confirms the account is linked. Unlinked players see only a full-screen holding page with their command/code and a refresh button; navigation, catalog, and product dialogs are unavailable. Failed checks keep the store locked and preserve the last code for retry. The server independently rejects purchase and gift-validation requests from unlinked accounts. Unconfigured Studio previews also start on this holding screen with a clearly labeled sample code, not a bypass into the store.
Unconfigured Studio sessions show the linking gate with a clearly labeled sample code; they do not bypass account requirements or allow checkout. Live mode uses /hub/getSession, the existing gift/order APIs, and the free-claim endpoint. Paid receipt fulfillment persists order intent and receipt IDs in DataStores: publish the place, enable HTTP/API access, and configure the backend before live checkout. Product downloads remain in the customer portal or Discord /retrieve, not the Roblox client.
The GUI draws edge-to-edge with ScreenInsets.None, SafeAreaCompatibility.None, and device-safe-area clipping disabled. It manually reserves the Roblox topbar button row (at least 64 pixels), including for product dialogs, without applying device safe zones. ReplicatedFirst.ClientStartup immediately disables all CoreGui with startup retries and logged failures. StarterGui.ScreenOrientation is saved as Portrait and also set by that client script. The place and server bootstrap both set gravity to zero to prevent avatars falling through the empty storefront world.
Owned product details hide terms acceptance when viewing your own copy; entering a gift recipient shows it again because gifting is a new purchase. The library explains run /retrieve <name>, and owned product details show the command with that product's actual name, without naming an external platform.
Parcel feature comparison
Compared against the original Parcel model previously included in this repository:
| Feature | MyHub status |
|---|---|
| Desktop/mobile navigation, welcome/logo, catalog and details | Implemented, with search/category/stock filters and sorting |
| Bestseller, sales count, owned count, Roblox username | Implemented using session data; bestseller opens its product |
| Creator identity and avatar/group emblem | Implemented; custom group branding takes precedence |
| Paid purchase, recipient validation, gifting and gift-disable setting | Wired to the backend and Roblox receipt flow; live checkout requires published-place/API configuration |
| Free products and owned library | Implemented; free grants are server-authoritative |
| Terms, About/description, account linking and errors | Implemented; linking command retained without naming an external platform |
| Background music toggle | Available in desktop sidebar and Account preferences on mobile |
| Ratings/review count | Implemented; linked owners rate 1–5 stars from product details, and cards/details show the average and review count |
| Product file delivery | Library and owned-product details show /retrieve <name> without naming a platform or displaying delivery URLs |
This is template/UI parity, not a claim that live Robux fulfillment has been end-to-end tested against a published production place.
Rebrand compatibility
MyHub replaces the former NotParcel/FORMA presentation. Existing database names, session cookie (np.sid), upload-directory identifier, Roblox HubStore instance names, and checkout DataStore keys remain stable so rebranding does not invalidate existing data or checkout records. Parcel-specific API URLs, parcelKey, and import settings still refer to the optional external Parcel integration, not the MyHub brand. Existing Discord application names/icons must be changed separately in the Discord Developer Portal; the app does not overwrite that account metadata.
Scripts
| Command | Description |
|---|---|
npm start |
Start the application |
npm run migrate |
Apply pending database migrations without starting the application |
npm test |
Verify hub generation, settings, store sessions, sales/payouts, usage tracking, ratings, and download flows |
npm run admin-token -- <hubId-or-discordGuildId> |
Generate a one-time admin portal login link |