vinejs / vine

VineJS is a form data validation library for Node.js
https://vinejs.dev
MIT License
1.06k stars 21 forks source link

Precompile not working #29

Closed pullmann4rent closed 7 months ago

pullmann4rent commented 7 months ago

Package version

1.7.1

Describe the bug

I want to precompile vinejs but not working if I precompile or not I got 20ms+ for a simple validation. Other libaries takes 1-3ms. So anything I doing it wrong.

Server.ts

import vine from '@vinejs/vine';
const app = express();

export const schemaTenantsAdmin = vine.object({
  email: vine.string().email(),
  password: vine.string().minLength(6).confirmed(),
  firstname: vine.string(),
  lastname: vine.string(),
  city: vine.string(),
  street: vine.string(),
  zipcode: vine.string(),
  category: vine.string(),
  company: vine.string(),
  domain: vine.string(),
  code: vine.number()
});
export const validatorVine = vine.compile(schemaTenantsAdmin);

app.use(morgan('dev'));
app.use(express.urlencoded({extended: true}));

//Reduce Fingerprint
app.disable('x-powered-by');

app.use(helmet());

// app.use(rateLimiter);

app.use('/api/auth', router_auth);

// Custom Error Handler
app.use(errorHandler);

app.listen(3000, () => {
 console.log('SERVER LISTEN ON PORT 3000');
});

SignUp.ts

export const SignUpTenantsAdmin = async (req: Request, res: Response) => {
  try {
    await validatorVine.validate(req.body);

    res.send('x');
  } catch(e) {
    Sentry.captureException(e);
    console.log(e);
    res.status(500).json(e);
  }
};

Reproduction repo

No response

RomainLanz commented 7 months ago

Hey @pullmann4rent! šŸ‘‹šŸ»

Please give us a repository with minimum application to reproduce the issue. Also, please add another validator so we can ensure your claim.

RomainLanz commented 7 months ago

Closing since no answer from issue reporter.