MockRequest.mjs 624 B

12345678910111213141516171819202122232425262728293031323334
  1. class MockRequest {
  2. constructor(vi) {
  3. this.session = { destroy() {} }
  4. this.ip = '42.42.42.42'
  5. this.headers = {}
  6. this.params = {}
  7. this.query = {}
  8. this.body = {}
  9. this._parsedUrl = {}
  10. this.i18n = {
  11. translate(str) {
  12. return str
  13. },
  14. }
  15. this.route = { path: '' }
  16. this.accepts = () => {}
  17. this.setHeader = () => {}
  18. this.logger = {
  19. addFields: vi.fn(),
  20. setLevel: vi.fn(),
  21. warn: vi.fn(),
  22. error: vi.fn(),
  23. info: vi.fn(),
  24. debug: vi.fn(),
  25. }
  26. }
  27. param(param) {
  28. return this.params[param]
  29. }
  30. }
  31. export default MockRequest