Leke
Leke
Explore posts from servers
KPCKevin Powell - Community
Created by Leke on 7/18/2023 in #back-end
AutoIncrement using mongoose
Please Guys what is the best way to implement AutoIncrement using mongoose, i tried the best two option and it wasnt working mongoose-sequence mongoose-auto-increment
const AutoIncrement = require('mongoose-sequence')(mongoose)

interface userTracks extends IUserTrack, mongoose.Document {}

const userModel = new mongoose.Schema(
{
fullName: {
type: String,
unique: false,
lowercase: true
},
email: {
type: String,
unique: true,
lowercase: true
},
phone: {
type: String
},
country: {
type: String,
unique: false,
lowercase: true
}
},
{ timestamps: true }
)

userModel.plugin(AutoIncrement, { inc_field: 'ticketNo', start_seq: 1000 })

export default mongoose.model<userTracks>('users', userModel)
const AutoIncrement = require('mongoose-sequence')(mongoose)

interface userTracks extends IUserTrack, mongoose.Document {}

const userModel = new mongoose.Schema(
{
fullName: {
type: String,
unique: false,
lowercase: true
},
email: {
type: String,
unique: true,
lowercase: true
},
phone: {
type: String
},
country: {
type: String,
unique: false,
lowercase: true
}
},
{ timestamps: true }
)

userModel.plugin(AutoIncrement, { inc_field: 'ticketNo', start_seq: 1000 })

export default mongoose.model<userTracks>('users', userModel)
6 replies
KPCKevin Powell - Community
Created by Leke on 6/13/2023 in #front-end
Attempted to load @next/swc-darwin-x64
I just created a new nextjs project and the first time i run the dev server i am seeing some errors in the console but the app running and i dont know if this will affect my project, please how do i resolve this issue?
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Using wasm build of next-swc
- warn Attempted to load @next/swc-darwin-x64, but an error occurred:
> next dev

- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Using wasm build of next-swc
- warn Attempted to load @next/swc-darwin-x64, but an error occurred:
1 replies
KPCKevin Powell - Community
Created by Leke on 5/29/2023 in #front-end
[vite-plugin-sass] Unexpected token u in JSON at position 0
I just migrated my react sass application from webpack to Vite but I haven’t been able to build since the migration took place. The error below is what I encounter
> vite build

vite v4.3.9 building for production...
125 modules transformed.
✓ built in 3.60s
[vite-plugin-sass] Unexpected token u in JSON at position 0
file: /Users/project/src/assets/css/sass/main.scss
error during build:
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object.transformReducer (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23567:81)
at file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:24590:140
at async transform (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23576:16)
at async ModuleLoader.addModuleSource (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23782:30)
> vite build

vite v4.3.9 building for production...
125 modules transformed.
✓ built in 3.60s
[vite-plugin-sass] Unexpected token u in JSON at position 0
file: /Users/project/src/assets/css/sass/main.scss
error during build:
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object.transformReducer (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23567:81)
at file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:24590:140
at async transform (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23576:16)
at async ModuleLoader.addModuleSource (file:///Users//node_modules/rollup/dist/es/shared/node-entry.js:23782:30)
main.scss
@use "./_01_mixins.scss" as *;
@use "./_02_variables" as *;
@use "./_03_core.scss" as *;
@use "./_04_plugins.scss" as *;
@use "./_05_views.scss" as *;
@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap");

/** your custom css code **/
#root {
min-width: 320px;
}
.container-fluid {
max-width: 2000px;
}
.btn-link,
.btn-link:hover {
font-weight: 500 !important;
}
a.white:hover,
a.white:active {
color: $theme-color-1 !important;
}
label {
font-weight: 600 !important;
font-size: 90% !important;
}
a,
button,
input,
.sidebar .main-menu ul li a {
transition: color 0.5s, border 0.5s, background 0.5s, opacity 0.5s,
height 0.5s;
}
.sidebar .main-menu ul li a {
padding: 0 10px;
line-height: 1.2;
text-align: center;
}
.btn-primary {
color: #fff !important;
}
.has-float-label label {
z-index: 10000;
}
@use "./_01_mixins.scss" as *;
@use "./_02_variables" as *;
@use "./_03_core.scss" as *;
@use "./_04_plugins.scss" as *;
@use "./_05_views.scss" as *;
@import url("https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap");

/** your custom css code **/
#root {
min-width: 320px;
}
.container-fluid {
max-width: 2000px;
}
.btn-link,
.btn-link:hover {
font-weight: 500 !important;
}
a.white:hover,
a.white:active {
color: $theme-color-1 !important;
}
label {
font-weight: 600 !important;
font-size: 90% !important;
}
a,
button,
input,
.sidebar .main-menu ul li a {
transition: color 0.5s, border 0.5s, background 0.5s, opacity 0.5s,
height 0.5s;
}
.sidebar .main-menu ul li a {
padding: 0 10px;
line-height: 1.2;
text-align: center;
}
.btn-primary {
color: #fff !important;
}
.has-float-label label {
z-index: 10000;
}
1 replies
KPCKevin Powell - Community
Created by Leke on 3/6/2023 in #front-end
React Query state management
Can other states management tools be ignored over React Query being used for state management in a react application?
8 replies
KPCKevin Powell - Community
Created by Leke on 3/1/2023 in #back-end
node-canvas error
node-canvas error
Is there any other library I can use since `node-canvas` seems to be an issue, please recommend.
Is there any other library I can use since `node-canvas` seems to be an issue, please recommend.
I tried using node-canvas with jsbarcode to process barcode from a node application but node-canvas seems to be an issue ever since I tried implementing using it.I have tried rebuilding from source yet the error still a blocker.
node:internal/modules/cjs/loader:1302
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen(/Users/mac/node_modules/canvas/build/Release/canvas.node, 1): Library not loaded: @loader_path/libpixman-1.0.42.2.dylib
Referenced from: /Users/mac/node_modules/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)

Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting…
node:internal/modules/cjs/loader:1302
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: dlopen(/Users/mac/node_modules/canvas/build/Release/canvas.node, 1): Library not loaded: @loader_path/libpixman-1.0.42.2.dylib
Referenced from: /Users/mac/node_modules/canvas/build/Release/canvas.node
Reason: no suitable image found. Did find:
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)
/Users/mac/node_modules/canvas/build/Release/libpixman-1.0.42.2.dylib: cannot load 'libpixman-1.0.42.2.dylib' (load command 0x80000034 is unknown)

Node.js v18.13.0
[nodemon] app crashed - waiting for file changes before starting…
4 replies
KPCKevin Powell - Community
Created by Leke on 2/22/2023 in #front-end
Build failed due to import error
Build failed due to import error After running the build command for my react app the build failed and the below is the response I get.
Creating an optimized production build...
Failed to compile.

Attempted import error: 'LowPriority' is not exported from 'scheduler' (imported as 'LowPriority’).
Creating an optimized production build...
Failed to compile.

Attempted import error: 'LowPriority' is not exported from 'scheduler' (imported as 'LowPriority’).
package.json
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
},
An ideal on how to resolve this issue will be much appreciated.
4 replies
KPCKevin Powell - Community
Created by Leke on 2/21/2023 in #front-end
Auto select country flag when country code is provided
I am working on a project and it is required I implement a functionality that allow users to provide their phone number in an input tag with the country code and immediately the country code is provided then the flag of the country appears respectively. Is there a library I can use to achieve this or an API?
5 replies
KPCKevin Powell - Community
Created by Leke on 2/8/2023 in #front-end
SCSS Error: can not read files in public path
I have an assets folder that contain some other files with images and svgs in it in the public file of my project so... => navbar.scss ...I declared a variable with path below
$logo-path: "/assets/logos/black.svg”;
$logo-path: "/assets/logos/black.svg”;
Error: Module not found: Error: Can't resolve '../../../logos/mobile.jpg’
Failed to compile.

Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes'
ERROR in ./src/assets/css/sass/themes/navbar.scss (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[0].oneOf[7].use[3]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[4]!./src/assets/css/sass/themes/navbar.scss) 5:36-100
Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes’
Failed to compile.

Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes'
ERROR in ./src/assets/css/sass/themes/navbar.scss (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[2]!./node_modules/resolve-url-loader/index.js??ruleSet[1].rules[0].oneOf[7].use[3]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[0].oneOf[7].use[4]!./src/assets/css/sass/themes/navbar.scss) 5:36-100
Module not found: Error: Can't resolve '../../../logos/mobile.jpg' in '/src/assets/css/sass/themes’
17 replies
KPCKevin Powell - Community
Created by Leke on 2/8/2023 in #back-end
`Cant install mongodb on mac`
4 replies
KPCKevin Powell - Community
Created by Leke on 2/6/2023 in #os-and-tools
0ver a 1000 accounts created per minute
I just discovered in the database that some accounts are being created with random emails, over 30,000 account have being created so far and i really don't know how to stop this, please who's got a better ideal on how to put a stop to this whole mess.
3 replies
KPCKevin Powell - Community
Created by Leke on 1/24/2023 in #back-end
How to make SQL Table Column data UNIQUE
I created this Clubs table in my SQL database but I want to make name row unique such that two rows will not have the same name.
CREATE TABLE clubs (
`id` integer PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`league` VARCHAR(45) NOT NULL,
`isActive` BOOLEAN,
created TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE TABLE clubs (
`id` integer PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`league` VARCHAR(45) NOT NULL,
`isActive` BOOLEAN,
created TIMESTAMP NOT NULL DEFAULT NOW()
);
5 replies
KPCKevin Powell - Community
Created by Leke on 1/18/2023 in #front-end
Tailwind CSS
Hello guys I just started using Tailwind CSS and I find it very interesting to use but I've got a question to ask. ⬇️ How else can Tailwind CSS be used without writing it inline html tags? Like is there another way to use it rather that just writing them in the tags, my code really looks ugly after writing lots of it in tags and I'm just curious. What if I've got a big project to work on ? Is that the only way to actually use tailwind?
16 replies
KPCKevin Powell - Community
Created by Leke on 1/17/2023 in #back-end
Sharp and Canvas error on Node
I have a project I'm trynna run for the first time, the codebase is an API backend written with express, so I tried running npm install script on it but some errors showed up about sharp and canvas which I really did install the two packages separately but when I tried running the project this error below keeps coming up.
node:internal/modules/cjs/loader:1203
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The specified procedure could not be found.
\\?\..api\node_modules\canvas\build\Release\canvas.node
node:internal/modules/cjs/loader:1203
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The specified procedure could not be found.
\\?\..api\node_modules\canvas\build\Release\canvas.node
I've seen some discussion regarding sharp and canvas that sharp wont run canvas which is why keep getting this error.
1 replies
KPCKevin Powell - Community
Created by Leke on 11/30/2022 in #front-end
How is option value string even after accepting a ``value={prop}`` of a number type?
6 replies
KPCKevin Powell - Community
Created by Leke on 11/27/2022 in #front-end
'paginationRange.length' is possibly 'undefined'.ts(18048)
6 replies
KPCKevin Powell - Community
Created by Leke on 11/22/2022 in #front-end
React Typescript Pagination Array Page Numbers
1 replies
KPCKevin Powell - Community
Created by Leke on 11/18/2022 in #front-end
can i export data isLoading error from reactQuery?
Please i need some help here. 🙏 I fetched data[] from an API using reactQuery but the problem I'm facing here is that i need to export all the properties decontructed from reactQuery such as the data[], isLoading, error so that i can be able to use it in another component, is this possible? I name the file userData.tsx
export const UserData = () => {
const { data, isLoading, error } = useQuery<User[], ErrorConstructor>("query-users", async () =>{
return await getAll()
})
if(error instanceof Error) return <div>Cannot fetch data</div>

if(isLoading) return <LoadingState/>

if(!data) return <div>Error occour</div>
return (
data
)
}
export const UserData = () => {
const { data, isLoading, error } = useQuery<User[], ErrorConstructor>("query-users", async () =>{
return await getAll()
})
if(error instanceof Error) return <div>Cannot fetch data</div>

if(isLoading) return <LoadingState/>

if(!data) return <div>Error occour</div>
return (
data
)
}
7 replies
KPCKevin Powell - Community
Created by Leke on 11/4/2022 in #front-end
React Typescript useContext
3 replies
KPCKevin Powell - Community
Created by Leke on 11/4/2022 in #front-end
React Typescript pageLayout
React Typescript pageLayout Hi everyone, I'm trying to achieve something and it seems very impossible with React && typescript. I have an application that has two header(s) at the top of every page, in this case the Login page takes Header1 and the dashboard page takes Header2, so the Header(s) depends on the page routing. Does anyone have an ideal on how to make this work ? I can also share what I have done as well for more clarity. Thank You. I have tried the same thing with just Nextjs and it worked but Typescript is making it look so hard.
1 replies
KPCKevin Powell - Community
Created by Leke on 11/3/2022 in #front-end
React Typescript SassError Undefined variable.
35 replies